diff --git a/src/index.ts b/src/index.ts index 950c32437..3abcadf32 100644 --- a/src/index.ts +++ b/src/index.ts @@ -80,7 +80,7 @@ class MemoryCache { fileContents = new Map() fileVersions = new Map() - constructor (public rootFileNames: string[] = []) { + constructor (rootFileNames: string[] = []) { for (const fileName of rootFileNames) this.fileVersions.set(fileName, 1) } } @@ -296,7 +296,7 @@ export function register (opts: Options = {}): Register { // Create the compiler host for type checking. const serviceHost: _ts.LanguageServiceHost = { - getScriptFileNames: () => memoryCache.rootFileNames, + getScriptFileNames: () => Array.from(memoryCache.fileVersions.keys()), getScriptVersion: (fileName: string) => { const version = memoryCache.fileVersions.get(fileName) return version === undefined ? '' : version.toString() @@ -335,9 +335,6 @@ export function register (opts: Options = {}): Register { const updateMemoryCache = function (contents: string, fileName: string) { const fileVersion = memoryCache.fileVersions.get(fileName) || 0 - // Add to `rootFiles` when discovered for the first time. - if (fileVersion === 0) memoryCache.rootFileNames.push(fileName) - // Avoid incrementing cache when nothing has changed. if (memoryCache.fileContents.get(fileName) === contents) return