build: support building with TypeScript 4.1 (#39571)

TypeScript 4.1 is now used to build and test within the repository.

PR Close #39571
This commit is contained in:
Charles Lyding
2020-11-04 19:58:29 -05:00
committed by Jessica Janiuk
parent a7e7c211b5
commit 318255a5f8
32 changed files with 93 additions and 69 deletions
@@ -48,6 +48,17 @@ const LOWER_FIELDS = ['useValue', 'useFactory', 'data', 'id', 'loadChildren'];
*/
const R3_LOWER_FIELDS = [...LOWER_FIELDS, 'providers', 'imports', 'exports'];
/**
* Installs a handler for testing purposes to allow inspection of the temporary program.
*/
let tempProgramHandlerForTest: ((program: ts.Program) => void)|null = null;
export function setTempProgramHandlerForTest(handler: (program: ts.Program) => void): void {
tempProgramHandlerForTest = handler;
}
export function resetTempProgramHandlerForTest(): void {
tempProgramHandlerForTest = null;
}
const emptyModules: NgAnalyzedModules = {
ngModules: [],
ngModuleByPipeOrDirective: new Map(),
@@ -618,6 +629,9 @@ class AngularCompilerProgram implements Program {
}
const tmpProgram = ts.createProgram(rootNames, this.options, this.hostAdapter, oldTsProgram);
if (tempProgramHandlerForTest !== null) {
tempProgramHandlerForTest(tmpProgram);
}
const sourceFiles: string[] = [];
const tsFiles: string[] = [];
tmpProgram.getSourceFiles().forEach(sf => {