Skip to content

Commit

Permalink
fix(compiler-cli): support hasInvalidatedResolutions.
Browse files Browse the repository at this point in the history
The latest TypeScript compiler exposes the previously private field
`hasInvalidatedResolutions`. That breaks Angular in the newer TS,
because the new field would be required on DelegatingCompilerHost.
However we cannot just add the field here, because it's not present in
the older compiler.

This change adds the field for delegation, which works at runtime
because the field is present. It suppresses the compiler error using a
`// @ts-expect-error`, which should be removed once Angular moves to a
TSC version that includes this change.
  • Loading branch information
mprobst committed Sep 29, 2022
1 parent 6a88bad commit 5034069
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/compiler-cli/src/ngtsc/core/src/host.ts
Expand Up @@ -68,6 +68,11 @@ export class DelegatingCompilerHost implements
useCaseSensitiveFileNames = this.delegateMethod('useCaseSensitiveFileNames');
writeFile = this.delegateMethod('writeFile');
getModuleResolutionCache = this.delegateMethod('getModuleResolutionCache');
// @ts-expect-error 'hasInvalidatedResolutions' is visible (and thus required here) in latest TSC
// main. It's already present, so the code works at runtime.
// TODO: remove this comment including the suppression once Angular uses a TSC version that
// includes this change.
hasInvalidatedResolutions = this.delegateMethod('hasInvalidatedResolutions');
}

/**
Expand Down
Expand Up @@ -52,6 +52,11 @@ export class DelegatingCompilerHost implements
trace = this.delegateMethod('trace');
useCaseSensitiveFileNames = this.delegateMethod('useCaseSensitiveFileNames');
getModuleResolutionCache = this.delegateMethod('getModuleResolutionCache');
// @ts-expect-error 'hasInvalidatedResolutions' is visible (and thus required here) in latest TSC
// main. It's already present, so the code works at runtime.
// TODO: remove this comment including the suppression once Angular uses a TSC version that
// includes this change.
hasInvalidatedResolutions = this.delegateMethod('hasInvalidatedResolutions');
}

/**
Expand Down

0 comments on commit 5034069

Please sign in to comment.