Skip to content

Always generate configFileDiag if file is going to be added to configured project #37443

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 1 commit into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/server/editorServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3017,6 +3017,13 @@ namespace ts.server {
// At this point if file is part of any any configured or external project, then it would be present in the containing projects
// So if it still doesnt have any containing projects, it needs to be part of inferred project
if (info.isOrphan()) {
// Even though this info did not belong to any of the configured projects, send the config file diag
if (isArray(retainProjects)) {
retainProjects.forEach(project => this.sendConfigFileDiagEvent(project, info.fileName));
}
else if (retainProjects) {
this.sendConfigFileDiagEvent(retainProjects, info.fileName);
}
Debug.assert(this.openFiles.has(info.path));
this.assignOrphanScriptInfoToInferredProject(info, this.openFiles.get(info.path));
}
Expand Down
28 changes: 26 additions & 2 deletions src/testRunner/unittests/tsserver/projectErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,10 @@ declare module '@custom/plugin' {
path: "/a/b/test.ts",
content: "let x = 10"
};
const file3: File = {
path: "/a/b/test2.ts",
content: "let xy = 10"
};
const configFile: File = {
path: "/a/b/tsconfig.json",
content: `{
Expand All @@ -618,9 +622,20 @@ declare module '@custom/plugin' {
"files": ["app.ts"]
}`
};
const serverEventManager = new TestServerEventManager([file, file2, libFile, configFile]);
const serverEventManager = new TestServerEventManager([file, file2, file3, libFile, configFile]);
openFilesForSession([file2], serverEventManager.session);
serverEventManager.checkSingleConfigFileDiagEvent(configFile.path, file2.path, [
getUnknownCompilerOptionDiagnostic(configFile, "foo"),
getUnknownCompilerOptionDiagnostic(configFile, "allowJS", "allowJs")
]);
openFilesForSession([file], serverEventManager.session);
// We generate only if project is created when opening file from the project
serverEventManager.hasZeroEvent("configFileDiag");
Copy link
Member Author

@sheetalkamat sheetalkamat Mar 17, 2020

Choose a reason for hiding this comment

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

@mjbvz Want you to ensure that this still holds. That is if file is opened from configured project, configFileDiag is generated only if project is created as part of the open operation

openFilesForSession([file3], serverEventManager.session);
serverEventManager.checkSingleConfigFileDiagEvent(configFile.path, file3.path, [
getUnknownCompilerOptionDiagnostic(configFile, "foo"),
getUnknownCompilerOptionDiagnostic(configFile, "allowJS", "allowJs")
]);
});

it("are not generated when the config file has errors but suppressDiagnosticEvents is true", () => {
Expand Down Expand Up @@ -651,16 +666,25 @@ declare module '@custom/plugin' {
path: "/a/b/test.ts",
content: "let x = 10"
};
const file3: File = {
path: "/a/b/test2.ts",
content: "let xy = 10"
};
const configFile: File = {
path: "/a/b/tsconfig.json",
content: `{
"files": ["app.ts"]
}`
};

const serverEventManager = new TestServerEventManager([file, file2, libFile, configFile]);
const serverEventManager = new TestServerEventManager([file, file2, file3, libFile, configFile]);
openFilesForSession([file2], serverEventManager.session);
serverEventManager.checkSingleConfigFileDiagEvent(configFile.path, file2.path, emptyArray);
openFilesForSession([file], serverEventManager.session);
// We generate only if project is created when opening file from the project
serverEventManager.hasZeroEvent("configFileDiag");
openFilesForSession([file3], serverEventManager.session);
serverEventManager.checkSingleConfigFileDiagEvent(configFile.path, file3.path, emptyArray);
});

it("contains the project reference errors", () => {
Expand Down