Skip to content

Commit

Permalink
feat: add support for using TypeScript 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-agius4 committed Nov 30, 2020
1 parent f45658a commit ffe3ab9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
"terser": "^5.0.0"
},
"peerDependencies": {
"@angular/compiler": "^11.0.0-next.0",
"@angular/compiler-cli": "^11.0.0-next.0",
"@angular/compiler": "^11.0.0",
"@angular/compiler-cli": "^11.0.0",
"tslib": "^2.0.0",
"typescript": "^4.0.0"
"typescript": ">=4.0 <4.2"
},
"devDependencies": {
"@angular/cdk": "^11.0.0",
Expand Down
6 changes: 4 additions & 2 deletions src/lib/ngc/compile-source-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function compileSourceFiles(

const scriptTarget = tsConfigOptions.target;
const cache = entryPoint.cache;
const oldProgram = cache.oldPrograms && (cache.oldPrograms[scriptTarget] as ng.Program | undefined);
const oldProgram = (cache.oldPrograms && cache.oldPrograms[scriptTarget]) as ng.Program | undefined;

const ngProgram = ng.createProgram({
rootNames: tsConfig.rootNames,
Expand All @@ -53,9 +53,11 @@ export async function compileSourceFiles(

await ngProgram.loadNgStructureAsync();

// TS 4.1+ stores the reuse state in the new program
const checkReuseProgram = (ts.versionMajorMinor as string) === '4.0' ? oldProgram : ngProgram;
log.debug(
`ngc program structure is reused: ${
oldProgram ? (oldProgram.getTsProgram() as any).structureIsReused : 'No old program'
checkReuseProgram ? (checkReuseProgram.getTsProgram() as any).structureIsReused : 'No old program'
}`,
);

Expand Down

0 comments on commit ffe3ab9

Please sign in to comment.