Skip to content

Commit a27f63d

Browse files
committed
refactor(@ngtools/webpack): expose TS TypeChecker from NG compiler plugin
Expose the TypeScript Program created by the plugin, so that it can be used in custom platform transformers.
1 parent 3000c8a commit a27f63d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/ngtools/webpack/src/angular_compiler_plugin.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ export class AngularCompilerPlugin {
174174
return { path, className };
175175
}
176176

177+
get typeChecker(): ts.TypeChecker | null {
178+
const tsProgram = this._getTsProgram();
179+
180+
return tsProgram ? tsProgram.getTypeChecker() : null;
181+
}
182+
177183
static isSupported() {
178184
return VERSION && parseInt(VERSION.major) >= 5;
179185
}
@@ -351,7 +357,7 @@ export class AngularCompilerPlugin {
351357
this._updateForkedTypeChecker(this._rootNames, this._getChangedCompilationFiles());
352358
}
353359

354-
// Use an identity function as all our paths are absolute already.
360+
// Use an identity function as all our paths are absolute already.
355361
this._moduleResolutionCache = ts.createModuleResolutionCache(this._basePath, x => x);
356362

357363
if (this._JitMode) {
@@ -1020,7 +1026,7 @@ export class AngularCompilerPlugin {
10201026
.map((resourcePath) => resolve(dirname(resolvedFileName), normalize(resourcePath)));
10211027

10221028
// These paths are meant to be used by the loader so we must denormalize them.
1023-
const uniqueDependencies = new Set([
1029+
const uniqueDependencies = new Set([
10241030
...esImports,
10251031
...resourceImports,
10261032
...this.getResourceDependencies(this._compilerHost.denormalizePath(resolvedFileName)),

0 commit comments

Comments
 (0)