From 7264c137114b6dd895624e3476dd7ec57b64ee13 Mon Sep 17 00:00:00 2001 From: Ahn Date: Mon, 26 Oct 2020 08:02:04 +0100 Subject: [PATCH] fix(compiler): only exclude test files when initializing compiler (#2062) Closes #2061 --- .../custom-typings/__tests__/index.test.ts | 10 +++++++--- e2e/__external-repos__/custom-typings/global.ts | 1 + src/compiler/language-service.ts | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 e2e/__external-repos__/custom-typings/global.ts diff --git a/e2e/__external-repos__/custom-typings/__tests__/index.test.ts b/e2e/__external-repos__/custom-typings/__tests__/index.test.ts index 725366c4b1..89b1ee87db 100644 --- a/e2e/__external-repos__/custom-typings/__tests__/index.test.ts +++ b/e2e/__external-repos__/custom-typings/__tests__/index.test.ts @@ -1,9 +1,13 @@ -import $ from "jquery" - function foo() { $.ajax("/foo") } -test("foo", () => { +test('foo', () => { expect(2).toBe(2) }) + +test('bar', () => { + const terminateReason: TerminatedReason = 'culled' + + expect(terminateReason).toEqual('culled') +}) diff --git a/e2e/__external-repos__/custom-typings/global.ts b/e2e/__external-repos__/custom-typings/global.ts new file mode 100644 index 0000000000..64e8d50c0e --- /dev/null +++ b/e2e/__external-repos__/custom-typings/global.ts @@ -0,0 +1 @@ +type TerminatedReason = 'culled' | 'died' | 'transferred' diff --git a/src/compiler/language-service.ts b/src/compiler/language-service.ts index 6528670bef..7dfacebe25 100644 --- a/src/compiler/language-service.ts +++ b/src/compiler/language-service.ts @@ -75,7 +75,7 @@ export const initializeLanguageServiceInstance = (configs: ConfigSet, logger: Lo } // Initialize memory cache for typescript compiler configs.parsedTsConfig.fileNames - .filter((fileName) => fileName.endsWith('.d.ts')) + .filter((fileName) => !configs.isTestFile(fileName)) .forEach((fileName) => { memoryCache.files.set(fileName, { version: 0,