Skip to content

Commit 238edf0

Browse files
authored
Merge pull request microsoft#14716 from Microsoft/fix14565
Do not report semantic diagnostics for infered and external projects with only .js files
2 parents 9c272ec + a710e94 commit 238edf0

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

src/harness/unittests/tsserverProjectSystem.ts

+36
Original file line numberDiff line numberDiff line change
@@ -3006,6 +3006,42 @@ namespace ts.projectSystem {
30063006
const errorResult = <protocol.Diagnostic[]>session.executeCommand(dTsFileGetErrRequest).response;
30073007
assert.isTrue(errorResult.length === 0);
30083008
});
3009+
3010+
it("should be turned on for js-only external projects with skipLibCheck=false", () => {
3011+
const jsFile = {
3012+
path: "/a/b/file1.js",
3013+
content: "let x =1;"
3014+
};
3015+
const dTsFile = {
3016+
path: "/a/b/file2.d.ts",
3017+
content: `
3018+
interface T {
3019+
name: string;
3020+
};
3021+
interface T {
3022+
name: number;
3023+
};`
3024+
};
3025+
const host = createServerHost([jsFile, dTsFile]);
3026+
const session = createSession(host);
3027+
3028+
const openExternalProjectRequest = makeSessionRequest<protocol.OpenExternalProjectArgs>(
3029+
CommandNames.OpenExternalProject,
3030+
{
3031+
projectFileName: "project1",
3032+
rootFiles: toExternalFiles([jsFile.path, dTsFile.path]),
3033+
options: { skipLibCheck: false }
3034+
}
3035+
);
3036+
session.executeCommand(openExternalProjectRequest);
3037+
3038+
const dTsFileGetErrRequest = makeSessionRequest<protocol.SemanticDiagnosticsSyncRequestArgs>(
3039+
CommandNames.SemanticDiagnosticsSync,
3040+
{ file: dTsFile.path }
3041+
);
3042+
const errorResult = <protocol.Diagnostic[]>session.executeCommand(dTsFileGetErrRequest).response;
3043+
assert.isTrue(errorResult.length === 0);
3044+
});
30093045
});
30103046

30113047
describe("non-existing directories listed in config file input array", () => {

src/server/session.ts

+1-8
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,7 @@ namespace ts.server {
2626
}
2727

2828
function shouldSkipSematicCheck(project: Project) {
29-
if (project.getCompilerOptions().skipLibCheck !== undefined) {
30-
return false;
31-
}
32-
33-
if ((project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) && project.isJsOnlyProject()) {
34-
return true;
35-
}
36-
return false;
29+
return (project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) && project.isJsOnlyProject();
3730
}
3831

3932
interface FileStart {

0 commit comments

Comments
 (0)