Skip to content

Commit

Permalink
fix(compiler-cli): support hasInvalidatedResolutions. (#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 #47585
  • Loading branch information
mprobst authored and AndrewKushnir committed Oct 4, 2022
1 parent c3f8579 commit 2e1ddde
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 2e1ddde

Please sign in to comment.