refactor: update angular to support TypeScript 2.4
Detailed updates: - rxjs@5.0.x - tsickle@0.24.x - typescript@2.4.x - @bazel/typescript@0.10.0 - protractor@5.1.x - selenium-webdriver@3.0.x BREAKING CHANGE: - the Angular compiler now requires TypeScript 2.4.x.
This commit is contained in:

committed by
Matias Niemelä

parent
112e777b90
commit
ca5aebaa6b
@ -137,23 +137,25 @@ export class TypeChecker {
|
||||
if (this._currentCancellationToken.isCancellationRequested()) return result;
|
||||
const sourceFile = program.getSourceFile(factoryName);
|
||||
for (const diagnostic of this.diagnosticProgram.getSemanticDiagnostics(sourceFile)) {
|
||||
const span = this.sourceSpanOf(diagnostic.file, diagnostic.start, diagnostic.length);
|
||||
if (span) {
|
||||
const fileName = span.start.file.url;
|
||||
const diagnosticsList = diagnosticsFor(fileName);
|
||||
diagnosticsList.push({
|
||||
messageText: diagnosticMessageToString(diagnostic.messageText),
|
||||
category: diagnostic.category, span,
|
||||
source: SOURCE,
|
||||
code: DEFAULT_ERROR_CODE
|
||||
});
|
||||
if (diagnostic.file && diagnostic.start) {
|
||||
const span = this.sourceSpanOf(diagnostic.file, diagnostic.start);
|
||||
if (span) {
|
||||
const fileName = span.start.file.url;
|
||||
const diagnosticsList = diagnosticsFor(fileName);
|
||||
diagnosticsList.push({
|
||||
messageText: diagnosticMessageToString(diagnostic.messageText),
|
||||
category: diagnostic.category, span,
|
||||
source: SOURCE,
|
||||
code: DEFAULT_ERROR_CODE
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private sourceSpanOf(source: ts.SourceFile, start: number, length: number): ParseSourceSpan|null {
|
||||
private sourceSpanOf(source: ts.SourceFile, start: number): ParseSourceSpan|null {
|
||||
// Find the corresponding TypeScript node
|
||||
const info = this.factories.get(source.fileName);
|
||||
if (info) {
|
||||
|
@ -193,7 +193,7 @@ class TypeScriptSymbolQuery implements SymbolQuery {
|
||||
const type = this.checker.getTypeAtLocation(parameter.type !);
|
||||
if (type.symbol !.name == 'TemplateRef' && isReferenceType(type)) {
|
||||
const typeReference = type as ts.TypeReference;
|
||||
if (typeReference.typeArguments.length === 1) {
|
||||
if (typeReference.typeArguments && typeReference.typeArguments.length === 1) {
|
||||
return typeReference.typeArguments[0].symbol;
|
||||
}
|
||||
}
|
||||
@ -261,7 +261,10 @@ class TypeWrapper implements Symbol {
|
||||
return this.context.checker.getNonNullableType(this.tsType) != this.tsType;
|
||||
}
|
||||
|
||||
get definition(): Definition { return definitionFromTsSymbol(this.tsType.getSymbol()); }
|
||||
get definition(): Definition|undefined {
|
||||
const symbol = this.tsType.getSymbol();
|
||||
return symbol ? definitionFromTsSymbol(symbol) : undefined;
|
||||
}
|
||||
|
||||
members(): SymbolTable {
|
||||
return new SymbolTableWrapper(this.tsType.getProperties(), this.context);
|
||||
@ -528,7 +531,10 @@ class PipeSymbol implements Symbol {
|
||||
|
||||
get public(): boolean { return true; }
|
||||
|
||||
get definition(): Definition { return definitionFromTsSymbol(this.tsType.getSymbol()); }
|
||||
get definition(): Definition|undefined {
|
||||
const symbol = this.tsType.getSymbol();
|
||||
return symbol ? definitionFromTsSymbol(symbol) : undefined;
|
||||
}
|
||||
|
||||
members(): SymbolTable { return EmptyTable.instance; }
|
||||
|
||||
|
@ -55,7 +55,11 @@ export function mainSync(
|
||||
}
|
||||
|
||||
function createEmitCallback(options: api.CompilerOptions): api.TsEmitCallback {
|
||||
const tsickleOptions: tsickle.TransformerOptions = {
|
||||
const tsickleHost: tsickle.TsickleHost = {
|
||||
shouldSkipTsickleProcessing: (fileName) => /\.d\.ts$/.test(fileName),
|
||||
pathToModuleName: (context, importPath) => '',
|
||||
shouldIgnoreWarningsForPath: (filePath) => false,
|
||||
fileNameToModuleId: (fileName) => fileName,
|
||||
googmodule: false,
|
||||
untyped: true,
|
||||
convertIndexImportShorthand: true,
|
||||
@ -63,13 +67,6 @@ function createEmitCallback(options: api.CompilerOptions): api.TsEmitCallback {
|
||||
transformTypesToClosure: options.annotateForClosureCompiler,
|
||||
};
|
||||
|
||||
const tsickleHost: tsickle.TransformerHost = {
|
||||
shouldSkipTsickleProcessing: (fileName) => /\.d\.ts$/.test(fileName),
|
||||
pathToModuleName: (context, importPath) => '',
|
||||
shouldIgnoreWarningsForPath: (filePath) => false,
|
||||
fileNameToModuleId: (fileName) => fileName,
|
||||
};
|
||||
|
||||
return ({
|
||||
program,
|
||||
targetSourceFile,
|
||||
@ -81,7 +78,7 @@ function createEmitCallback(options: api.CompilerOptions): api.TsEmitCallback {
|
||||
options
|
||||
}) =>
|
||||
tsickle.emitWithTsickle(
|
||||
program, tsickleHost, tsickleOptions, host, options, targetSourceFile, writeFile,
|
||||
program, tsickleHost, host, options, targetSourceFile, writeFile,
|
||||
cancellationToken, emitOnlyDtsFiles, {
|
||||
beforeTs: customTransformers.before,
|
||||
afterTs: customTransformers.after,
|
||||
|
@ -142,8 +142,8 @@ export function performCompilation({rootNames, options, host, oldProgram, emitCa
|
||||
}): PerformCompilationResult {
|
||||
const [major, minor] = ts.version.split('.');
|
||||
|
||||
if (Number(major) < 2 || (Number(major) === 2 && Number(minor) < 3)) {
|
||||
throw new Error('Must use TypeScript > 2.3 to have transformer support');
|
||||
if (Number(major) < 2 || (Number(major) === 2 && Number(minor) < 4)) {
|
||||
throw new Error('The Angular Compiler requires TypeScript >= 2.4.');
|
||||
}
|
||||
|
||||
let program: api.Program|undefined;
|
||||
|
@ -190,7 +190,7 @@ class _NodeEmitterVisitor implements StatementVisitor, ExpressionVisitor {
|
||||
// TODO {chuckj}: Determine what should be done for a method with a null name.
|
||||
const methods = stmt.methods.filter(method => method.name)
|
||||
.map(
|
||||
method => ts.createMethodDeclaration(
|
||||
method => ts.createMethod(
|
||||
/* decorators */ undefined, /* modifiers */ undefined,
|
||||
/* astriskToken */ undefined, method.name !/* guarded by filter */,
|
||||
/* questionToken */ undefined, /* typeParameters */ undefined,
|
||||
|
Reference in New Issue
Block a user