Skip to content

Commit

Permalink
fix(compiler-cli): support hasInvalidatedResolutions. (angular#47585)
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.

PR Close angular#47585
  • Loading branch information
mprobst authored and yharaskrik committed Oct 5, 2022
1 parent 2a89cc7 commit 565e0d9
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 (github.com/microsoft/TypeScript@a455955).
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 (github.com/microsoft/TypeScript@a455955).
hasInvalidatedResolutions = this.delegateMethod('hasInvalidatedResolutions');
}

/**
Expand Down

0 comments on commit 565e0d9

Please sign in to comment.