From a710e9433b28c0c9b692ad6244415777ec3d565d Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 17 Mar 2017 17:20:43 -0700 Subject: [PATCH] Do not report semantic diagnostics for infered and external projects with only .js files --- .../unittests/tsserverProjectSystem.ts | 36 +++++++++++++++++++ src/server/session.ts | 9 +---- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index a13835fa7f3..5ea0df91caa 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -3006,6 +3006,42 @@ namespace ts.projectSystem { const errorResult = session.executeCommand(dTsFileGetErrRequest).response; assert.isTrue(errorResult.length === 0); }); + + it("should be turned on for js-only external projects with skipLibCheck=false", () => { + const jsFile = { + path: "/a/b/file1.js", + content: "let x =1;" + }; + const dTsFile = { + path: "/a/b/file2.d.ts", + content: ` + interface T { + name: string; + }; + interface T { + name: number; + };` + }; + const host = createServerHost([jsFile, dTsFile]); + const session = createSession(host); + + const openExternalProjectRequest = makeSessionRequest( + CommandNames.OpenExternalProject, + { + projectFileName: "project1", + rootFiles: toExternalFiles([jsFile.path, dTsFile.path]), + options: { skipLibCheck: false } + } + ); + session.executeCommand(openExternalProjectRequest); + + const dTsFileGetErrRequest = makeSessionRequest( + CommandNames.SemanticDiagnosticsSync, + { file: dTsFile.path } + ); + const errorResult = session.executeCommand(dTsFileGetErrRequest).response; + assert.isTrue(errorResult.length === 0); + }); }); describe("non-existing directories listed in config file input array", () => { diff --git a/src/server/session.ts b/src/server/session.ts index f82d11ba91b..8dd0411d077 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -26,14 +26,7 @@ namespace ts.server { } function shouldSkipSematicCheck(project: Project) { - if (project.getCompilerOptions().skipLibCheck !== undefined) { - return false; - } - - if ((project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) && project.isJsOnlyProject()) { - return true; - } - return false; + return (project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) && project.isJsOnlyProject(); } interface FileStart {