@@ -81,7 +81,7 @@ class MemoryCache {
81
81
fileContents = new Map < string , string > ( )
82
82
fileVersions = new Map < string , number > ( )
83
83
84
- constructor ( rootFileNames : string [ ] = [ ] ) {
84
+ constructor ( public rootFileNames : string [ ] = [ ] ) {
85
85
for ( const fileName of rootFileNames ) this . fileVersions . set ( fileName , 1 )
86
86
}
87
87
}
@@ -293,7 +293,7 @@ export function register (opts: Options = {}): Register {
293
293
294
294
// Create the compiler host for type checking.
295
295
const serviceHost : _ts . LanguageServiceHost = {
296
- getScriptFileNames : ( ) => Array . from ( memoryCache . fileVersions . keys ( ) ) ,
296
+ getScriptFileNames : ( ) => memoryCache . rootFileNames ,
297
297
getScriptVersion : ( fileName : string ) => {
298
298
const version = memoryCache . fileVersions . get ( fileName )
299
299
return version === undefined ? '' : version . toString ( )
@@ -332,6 +332,9 @@ export function register (opts: Options = {}): Register {
332
332
const updateMemoryCache = ( contents : string , fileName : string ) => {
333
333
const fileVersion = memoryCache . fileVersions . get ( fileName ) || 0
334
334
335
+ // Add to `rootFiles` when discovered for the first time.
336
+ if ( fileVersion === 0 ) memoryCache . rootFileNames . push ( fileName )
337
+
335
338
// Avoid incrementing cache when nothing has changed.
336
339
if ( memoryCache . fileContents . get ( fileName ) === contents ) return
337
340
0 commit comments