Skip to content

Commit a7e7c21

Browse files
clydinthePunderWoman
authored andcommitted
feat(compiler-cli): add support for using TypeScript 4.1 (angular#39571)
This change enables projects to be built with TypeScript 4.1. Support for TypeScript 4.0 is also retained. PR Close angular#39571
1 parent 2786292 commit a7e7c21

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

packages/compiler-cli/src/transformers/program.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,10 @@ class AngularCompilerProgram implements Program {
654654
// - we cache all the files in the hostAdapter
655655
// - new new stubs use the exactly same imports/exports as the old once (we assert that in
656656
// hostAdapter.updateGeneratedFile).
657-
if (tsStructureIsReused(tmpProgram) !== StructureIsReused.Completely) {
657+
// TS 4.1+ stores the reuse state in the new program
658+
const checkReuseProgram =
659+
(ts.versionMajorMinor as string) === '4.0' ? tmpProgram : this._tsProgram;
660+
if (tsStructureIsReused(checkReuseProgram) !== StructureIsReused.Completely) {
658661
throw new Error(`Internal Error: The structure of the program changed during codegen.`);
659662
}
660663
}

packages/compiler-cli/src/typescript_support.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const MIN_TS_VERSION = '4.0.0';
2525
* Note: this check is disabled in g3, search for
2626
* `angularCompilerOptions.disableTypeScriptVersionCheck` config param value in g3.
2727
*/
28-
const MAX_TS_VERSION = '4.1.0';
28+
const MAX_TS_VERSION = '4.2.0';
2929

3030
/**
3131
* The currently used version of TypeScript, which can be adjusted for testing purposes using

0 commit comments

Comments
 (0)