@@ -350,7 +350,7 @@ export class CompilerHost implements ts.CompilerHost {
350
350
return vpath . resolve ( this . getDefaultLibLocation ( ) , ts . getDefaultLibFileName ( options ) ) ;
351
351
}
352
352
353
- public getSourceFile ( fileName : string , languageVersion : number ) : ts . SourceFile | undefined {
353
+ public getSourceFile ( fileName : string , languageVersionOrOptions : ts . ScriptTarget | ts . CreateSourceFileOptions ) : ts . SourceFile | undefined {
354
354
const canonicalFileName = this . getCanonicalFileName ( vpath . resolve ( this . getCurrentDirectory ( ) , fileName ) ) ;
355
355
const existing = this . _sourceFiles . get ( canonicalFileName ) ;
356
356
if ( existing ) return existing ;
@@ -364,7 +364,7 @@ export class CompilerHost implements ts.CompilerHost {
364
364
// reused across multiple tests. In that case, we cache the SourceFile we parse
365
365
// so that it can be reused across multiple tests to avoid the cost of
366
366
// repeatedly parsing the same file over and over (such as lib.d.ts).
367
- const cacheKey = this . vfs . shadowRoot && `SourceFile[languageVersion =${ languageVersion } ,setParentNodes=${ this . _setParentNodes } ]` ;
367
+ const cacheKey = this . vfs . shadowRoot && `SourceFile[languageVersionOrOptions =${ languageVersionOrOptions !== undefined ? JSON . stringify ( languageVersionOrOptions ) : undefined } ,setParentNodes=${ this . _setParentNodes } ]` ;
368
368
if ( cacheKey ) {
369
369
const meta = this . vfs . filemeta ( canonicalFileName ) ;
370
370
const sourceFileFromMetadata = meta . get ( cacheKey ) as ts . SourceFile | undefined ;
@@ -374,7 +374,7 @@ export class CompilerHost implements ts.CompilerHost {
374
374
}
375
375
}
376
376
377
- const parsed = ts . createSourceFile ( fileName , content , languageVersion , this . _setParentNodes || this . shouldAssertInvariants ) ;
377
+ const parsed = ts . createSourceFile ( fileName , content , languageVersionOrOptions , this . _setParentNodes || this . shouldAssertInvariants ) ;
378
378
if ( this . shouldAssertInvariants ) {
379
379
Utils . assertInvariants ( parsed , /*parent*/ undefined ) ;
380
380
}
0 commit comments