@@ -23,43 +23,68 @@ import {FileUpdate, MaybeSourceFileWithOriginalFile, NgOriginalFile, ProgramDriv
2323 */
2424export class DelegatingCompilerHost implements
2525 Omit < RequiredDelegations < ts . CompilerHost > , 'getSourceFile' | 'fileExists' | 'writeFile' > {
26- constructor ( protected delegate : ts . CompilerHost ) { }
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+ }
2783
2884 private delegateMethod < M extends keyof ts . CompilerHost > ( name : M ) : ts . CompilerHost [ M ] {
2985 return this . delegate [ name ] !== undefined ? ( this . delegate [ name ] as any ) . bind ( this . delegate ) :
3086 undefined ;
3187 }
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' ) ;
6388}
6489
6590/**
@@ -81,12 +106,13 @@ class UpdatedProgramHost extends DelegatingCompilerHost {
81106 * order for those shims to be loaded, and then cleaned up afterwards. Thus the
82107 * `UpdatedProgramHost` has its own `ShimReferenceTagger` to perform this function.
83108 */
84- private shimTagger = new ShimReferenceTagger ( this . shimExtensionPrefixes ) ;
109+ private shimTagger : ShimReferenceTagger ;
85110
86111 constructor (
87112 sfMap : Map < string , ts . SourceFile > , private originalProgram : ts . Program ,
88113 delegate : ts . CompilerHost , private shimExtensionPrefixes : string [ ] ) {
89114 super ( delegate ) ;
115+ this . shimTagger = new ShimReferenceTagger ( this . shimExtensionPrefixes ) ;
90116 this . sfMap = sfMap ;
91117 }
92118
@@ -150,11 +176,13 @@ export class TsCreateProgramDriver implements ProgramDriver {
150176 */
151177 private sfMap = new Map < string , ts . SourceFile > ( ) ;
152178
153- private program : ts . Program = this . originalProgram ;
179+ private program : ts . Program ;
154180
155181 constructor (
156182 private originalProgram : ts . Program , private originalHost : ts . CompilerHost ,
157- private options : ts . CompilerOptions , private shimExtensionPrefixes : string [ ] ) { }
183+ private options : ts . CompilerOptions , private shimExtensionPrefixes : string [ ] ) {
184+ this . program = this . originalProgram ;
185+ }
158186
159187 readonly supportsInlineOperations = true ;
160188
0 commit comments