@@ -23,68 +23,43 @@ import {FileUpdate, MaybeSourceFileWithOriginalFile, NgOriginalFile, ProgramDriv
2323 */
2424export class DelegatingCompilerHost implements
2525 Omit < RequiredDelegations < ts . CompilerHost > , 'getSourceFile' | 'fileExists' | 'writeFile' > {
26- createHash ;
27- directoryExists ;
28- getCancellationToken ;
29- getCanonicalFileName ;
30- getCurrentDirectory ;
31- getDefaultLibFileName ;
32- getDefaultLibLocation ;
33- getDirectories ;
34- getEnvironmentVariable ;
35- getNewLine ;
36- getParsedCommandLine ;
37- getSourceFileByPath ;
38- readDirectory ;
39- readFile ;
40- realpath ;
41- resolveModuleNames ;
42- resolveTypeReferenceDirectives ;
43- trace ;
44- useCaseSensitiveFileNames ;
45- getModuleResolutionCache ;
46- hasInvalidatedResolutions ;
47- resolveModuleNameLiterals ;
48- resolveTypeReferenceDirectiveReferences ;
49-
50- constructor ( protected delegate : ts . CompilerHost ) {
51- // Excluded are 'getSourceFile', 'fileExists' and 'writeFile', which are actually implemented by
52- // `TypeCheckProgramHost` below.
53-
54- this . createHash = this . delegateMethod ( 'createHash' ) ;
55- this . directoryExists = this . delegateMethod ( 'directoryExists' ) ;
56- this . getCancellationToken = this . delegateMethod ( 'getCancellationToken' ) ;
57- this . getCanonicalFileName = this . delegateMethod ( 'getCanonicalFileName' ) ;
58- this . getCurrentDirectory = this . delegateMethod ( 'getCurrentDirectory' ) ;
59- this . getDefaultLibFileName = this . delegateMethod ( 'getDefaultLibFileName' ) ;
60- this . getDefaultLibLocation = this . delegateMethod ( 'getDefaultLibLocation' ) ;
61- this . getDirectories = this . delegateMethod ( 'getDirectories' ) ;
62- this . getEnvironmentVariable = this . delegateMethod ( 'getEnvironmentVariable' ) ;
63- this . getNewLine = this . delegateMethod ( 'getNewLine' ) ;
64- this . getParsedCommandLine = this . delegateMethod ( 'getParsedCommandLine' ) ;
65- this . getSourceFileByPath = this . delegateMethod ( 'getSourceFileByPath' ) ;
66- this . readDirectory = this . delegateMethod ( 'readDirectory' ) ;
67- this . readFile = this . delegateMethod ( 'readFile' ) ;
68- this . realpath = this . delegateMethod ( 'realpath' ) ;
69- this . resolveModuleNames = this . delegateMethod ( 'resolveModuleNames' ) ;
70- this . resolveTypeReferenceDirectives = this . delegateMethod ( 'resolveTypeReferenceDirectives' ) ;
71- this . trace = this . delegateMethod ( 'trace' ) ;
72- this . useCaseSensitiveFileNames = this . delegateMethod ( 'useCaseSensitiveFileNames' ) ;
73- this . getModuleResolutionCache = this . delegateMethod ( 'getModuleResolutionCache' ) ;
74- this . hasInvalidatedResolutions = this . delegateMethod ( 'hasInvalidatedResolutions' ) ;
75- // The following methods are required in TS 5.0+, but they don't exist in earlier versions.
76- // TODO(crisbeto): remove the `ts-ignore` when dropping support for TypeScript 4.9.
77- // @ts -ignore
78- this . resolveModuleNameLiterals = this . delegateMethod ( 'resolveModuleNameLiterals' ) ;
79- this . resolveTypeReferenceDirectiveReferences =
80- // @ts -ignore
81- this . delegateMethod ( 'resolveTypeReferenceDirectiveReferences' ) ;
82- }
26+ constructor ( protected delegate : ts . CompilerHost ) { }
8327
8428 private delegateMethod < M extends keyof ts . CompilerHost > ( name : M ) : ts . CompilerHost [ M ] {
8529 return this . delegate [ name ] !== undefined ? ( this . delegate [ name ] as any ) . bind ( this . delegate ) :
8630 undefined ;
8731 }
32+
33+ // Excluded are 'getSourceFile', 'fileExists' and 'writeFile', which are actually implemented by
34+ // `TypeCheckProgramHost` below.
35+ createHash = this . delegateMethod ( 'createHash' ) ;
36+ directoryExists = this . delegateMethod ( 'directoryExists' ) ;
37+ getCancellationToken = this . delegateMethod ( 'getCancellationToken' ) ;
38+ getCanonicalFileName = this . delegateMethod ( 'getCanonicalFileName' ) ;
39+ getCurrentDirectory = this . delegateMethod ( 'getCurrentDirectory' ) ;
40+ getDefaultLibFileName = this . delegateMethod ( 'getDefaultLibFileName' ) ;
41+ getDefaultLibLocation = this . delegateMethod ( 'getDefaultLibLocation' ) ;
42+ getDirectories = this . delegateMethod ( 'getDirectories' ) ;
43+ getEnvironmentVariable = this . delegateMethod ( 'getEnvironmentVariable' ) ;
44+ getNewLine = this . delegateMethod ( 'getNewLine' ) ;
45+ getParsedCommandLine = this . delegateMethod ( 'getParsedCommandLine' ) ;
46+ getSourceFileByPath = this . delegateMethod ( 'getSourceFileByPath' ) ;
47+ readDirectory = this . delegateMethod ( 'readDirectory' ) ;
48+ readFile = this . delegateMethod ( 'readFile' ) ;
49+ realpath = this . delegateMethod ( 'realpath' ) ;
50+ resolveModuleNames = this . delegateMethod ( 'resolveModuleNames' ) ;
51+ resolveTypeReferenceDirectives = this . delegateMethod ( 'resolveTypeReferenceDirectives' ) ;
52+ trace = this . delegateMethod ( 'trace' ) ;
53+ useCaseSensitiveFileNames = this . delegateMethod ( 'useCaseSensitiveFileNames' ) ;
54+ getModuleResolutionCache = this . delegateMethod ( 'getModuleResolutionCache' ) ;
55+ hasInvalidatedResolutions = this . delegateMethod ( 'hasInvalidatedResolutions' ) ;
56+ // The following methods are required in TS 5.0+, but they don't exist in earlier versions.
57+ // TODO(crisbeto): remove the `ts-ignore` when dropping support for TypeScript 4.9.
58+ // @ts -ignore
59+ resolveModuleNameLiterals = this . delegateMethod ( 'resolveModuleNameLiterals' ) ;
60+ resolveTypeReferenceDirectiveReferences =
61+ // @ts -ignore
62+ this . delegateMethod ( 'resolveTypeReferenceDirectiveReferences' ) ;
8863}
8964
9065/**
@@ -106,13 +81,12 @@ class UpdatedProgramHost extends DelegatingCompilerHost {
10681 * order for those shims to be loaded, and then cleaned up afterwards. Thus the
10782 * `UpdatedProgramHost` has its own `ShimReferenceTagger` to perform this function.
10883 */
109- private shimTagger : ShimReferenceTagger ;
84+ private shimTagger = new ShimReferenceTagger ( this . shimExtensionPrefixes ) ;
11085
11186 constructor (
11287 sfMap : Map < string , ts . SourceFile > , private originalProgram : ts . Program ,
11388 delegate : ts . CompilerHost , private shimExtensionPrefixes : string [ ] ) {
11489 super ( delegate ) ;
115- this . shimTagger = new ShimReferenceTagger ( this . shimExtensionPrefixes ) ;
11690 this . sfMap = sfMap ;
11791 }
11892
@@ -176,13 +150,11 @@ export class TsCreateProgramDriver implements ProgramDriver {
176150 */
177151 private sfMap = new Map < string , ts . SourceFile > ( ) ;
178152
179- private program : ts . Program ;
153+ private program : ts . Program = this . originalProgram ;
180154
181155 constructor (
182156 private originalProgram : ts . Program , private originalHost : ts . CompilerHost ,
183- private options : ts . CompilerOptions , private shimExtensionPrefixes : string [ ] ) {
184- this . program = this . originalProgram ;
185- }
157+ private options : ts . CompilerOptions , private shimExtensionPrefixes : string [ ] ) { }
186158
187159 readonly supportsInlineOperations = true ;
188160
0 commit comments