From 3fbd47394a675358886e67e3f40115d392a83fcf Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 7 Jul 2020 12:00:03 -0700 Subject: [PATCH] Dont include auto type reference directives --- src/server/project.ts | 1 + .../tsserver/semanticOperationsOnSyntaxServer.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/server/project.ts b/src/server/project.ts index b561d1e92e31d..2edb225fee734 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -282,6 +282,7 @@ namespace ts.server { this.languageServiceEnabled = true; if (projectService.syntaxOnly) { this.compilerOptions.noResolve = true; + this.compilerOptions.types = []; } this.setInternalCompilerOptionsForEmittingJsFiles(); diff --git a/src/testRunner/unittests/tsserver/semanticOperationsOnSyntaxServer.ts b/src/testRunner/unittests/tsserver/semanticOperationsOnSyntaxServer.ts index de2e2c9753f68..09b6df7c42ae8 100644 --- a/src/testRunner/unittests/tsserver/semanticOperationsOnSyntaxServer.ts +++ b/src/testRunner/unittests/tsserver/semanticOperationsOnSyntaxServer.ts @@ -95,5 +95,19 @@ class c { prop = "hello"; foo() { return this.prop; } }` } assert.isTrue(hasException); }); + + it("should not include auto type reference directives", () => { + const { host, session, file1 } = setup(); + const atTypes: File = { + path: `/node_modules/@types/somemodule/index.d.ts`, + content: "export const something = 10;" + }; + host.ensureFileOrFolder(atTypes); + const service = session.getProjectService(); + openFilesForSession([file1], session); + checkNumberOfProjects(service, { inferredProjects: 1 }); + const project = service.inferredProjects[0]; + checkProjectActualFiles(project, [libFile.path, file1.path]); // Should not contain atTypes + }); }); }