Skip to content

Tolerate non-existing files specified for tsserver #8504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 19, 2016

Conversation

zhengbli
Copy link
Contributor

@zhengbli zhengbli commented May 6, 2016

Fixes #8334. Now in the tsserver scenerio, if a file specified in tsconfig.json was not found, an config diagnostic event will be emitted, while the rest of the project will continue functioning.

@zhengbli zhengbli changed the title Tolerate non-existing files specified Tolerate non-existing files specified for tsserver May 6, 2016
for (const rootFilename of projectOptions.files) {
if (this.host.fileExists(rootFilename)) {
const info = this.openFile(rootFilename, /*openedByClient*/ clientFileName == rootFilename);
project.addRoot(info);
}
else {
const error = createCompilerDiagnostic(Diagnostics.File_0_not_found, rootFilename);
return { success: false, errors: [error] };
errors.push(createCompilerDiagnostic(Diagnostics.File_0_not_found, rootFilename));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using this pattern:

const errors:  Diagnostic[];
...
(errors || errors = []).push(createCompilerDiagnostic(Diagnostics.File_0_not_found, rootFilename));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saves you the allocation in the normal case.

@mhegazy
Copy link
Contributor

mhegazy commented May 6, 2016

Can you add a fourslash test for this?

@mhegazy
Copy link
Contributor

mhegazy commented May 17, 2016

👍

@zhengbli zhengbli merged commit e8862a7 into microsoft:master May 19, 2016
@zhengbli zhengbli deleted the i8334 branch May 19, 2016 23:52
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants