diff --git a/packages/compiler-cli/src/transformers/program.ts b/packages/compiler-cli/src/transformers/program.ts index d8af2c9f62..b7abbfc535 100644 --- a/packages/compiler-cli/src/transformers/program.ts +++ b/packages/compiler-cli/src/transformers/program.ts @@ -654,7 +654,10 @@ class AngularCompilerProgram implements Program { // - we cache all the files in the hostAdapter // - new new stubs use the exactly same imports/exports as the old once (we assert that in // hostAdapter.updateGeneratedFile). - if (tsStructureIsReused(tmpProgram) !== StructureIsReused.Completely) { + // TS 4.1+ stores the reuse state in the new program + const checkReuseProgram = + (ts.versionMajorMinor as string) === '4.0' ? tmpProgram : this._tsProgram; + if (tsStructureIsReused(checkReuseProgram) !== StructureIsReused.Completely) { throw new Error(`Internal Error: The structure of the program changed during codegen.`); } } diff --git a/packages/compiler-cli/src/typescript_support.ts b/packages/compiler-cli/src/typescript_support.ts index 4404033259..efdd34c8de 100644 --- a/packages/compiler-cli/src/typescript_support.ts +++ b/packages/compiler-cli/src/typescript_support.ts @@ -25,7 +25,7 @@ const MIN_TS_VERSION = '4.0.0'; * Note: this check is disabled in g3, search for * `angularCompilerOptions.disableTypeScriptVersionCheck` config param value in g3. */ -const MAX_TS_VERSION = '4.1.0'; +const MAX_TS_VERSION = '4.2.0'; /** * The currently used version of TypeScript, which can be adjusted for testing purposes using