build: upgrade to TypeScript 2.7 (#22669)

Fixes: #21571

PR Close #22669
This commit is contained in:
Chuck Jazdzewski
2018-02-08 08:59:25 -08:00
committed by Kara Erickson
parent a225b48482
commit 8449eb8d62
30 changed files with 222 additions and 162 deletions

View File

@ -46,7 +46,9 @@ export function getClassMembers(
if (declaration) {
const type = checker.getTypeAtLocation(declaration);
const node = program.getSourceFile(staticSymbol.filePath);
return new TypeWrapper(type, {node, program, checker}).members();
if (node) {
return new TypeWrapper(type, {node, program, checker}).members();
}
}
}

View File

@ -190,9 +190,12 @@ export function getExpressionLoweringTransformFactory(
// Return the factory
return (context: ts.TransformationContext) => (sourceFile: ts.SourceFile): ts.SourceFile => {
// We need to use the original SourceFile for reading metadata, and not the transformed one.
const requests = requestsMap.getRequests(program.getSourceFile(sourceFile.fileName));
if (requests && requests.size) {
return transformSourceFile(sourceFile, requests, context);
const originalFile = program.getSourceFile(sourceFile.fileName);
if (originalFile) {
const requests = requestsMap.getRequests(originalFile);
if (requests && requests.size) {
return transformSourceFile(sourceFile, requests, context);
}
}
return sourceFile;
};

View File

@ -73,9 +73,9 @@ class AngularCompilerProgram implements Program {
private host: CompilerHost, oldProgram?: Program) {
this.rootNames = [...rootNames];
if (ts.version < '2.4.2' || (ts.version >= '2.7.0' && !options.disableTypeScriptVersionCheck)) {
if (ts.version < '2.7.2' || (ts.version >= '2.8.0' && !options.disableTypeScriptVersionCheck)) {
throw new Error(
`The Angular Compiler requires TypeScript >=2.4.2 and <2.7 but ${ts.version} was found instead.`);
`The Angular Compiler requires TypeScript >=2.7.2 and <2.8.0 but ${ts.version} was found instead.`);
}
this.oldTsProgram = oldProgram ? oldProgram.getTsProgram() : undefined;
@ -304,7 +304,10 @@ class AngularCompilerProgram implements Program {
genFile = genFileByFileName.get(sourceFile.fileName);
if (!sourceFile.isDeclarationFile && !GENERATED_FILES.test(sourceFile.fileName)) {
// Note: sourceFile is the transformed sourcefile, not the original one!
emittedSourceFiles.push(this.tsProgram.getSourceFile(sourceFile.fileName));
const originalFile = this.tsProgram.getSourceFile(sourceFile.fileName);
if (originalFile) {
emittedSourceFiles.push(originalFile);
}
}
}
this.writeFile(outFileName, outData, writeByteOrderMark, onError, genFile, sourceFiles);