refactor: allow compilation with TypeScript 2.5 (#19966)

A small number of types need to be adjusted. The changes seem to be
backwards compatible with TS 2.4.

PR Close #19966
This commit is contained in:
Rado Kirov 2017-10-26 17:23:30 -07:00 committed by Matias Niemelä
parent 7553ce9dfe
commit 005a78bd83
4 changed files with 19 additions and 8 deletions

View File

@ -81,7 +81,9 @@ export class Runner {
{provide: WebDriverAdapter, useValue: adapter} {provide: WebDriverAdapter, useValue: adapter}
]); ]);
const sampler = injector.get(Sampler); // TODO: With TypeScript 2.5 injector.get does not infer correctly the
// return type. Remove 'any' and investigate the issue.
const sampler = injector.get(Sampler) as any;
return sampler.sample(); return sampler.sample();
}); });
} }

View File

@ -116,8 +116,8 @@ export class MetadataCollector {
function classMetadataOf(classDeclaration: ts.ClassDeclaration): ClassMetadata { function classMetadataOf(classDeclaration: ts.ClassDeclaration): ClassMetadata {
const result: ClassMetadata = {__symbolic: 'class'}; const result: ClassMetadata = {__symbolic: 'class'};
function getDecorators(decorators: ts.Decorator[] | undefined): MetadataSymbolicExpression[]| function getDecorators(decorators: ReadonlyArray<ts.Decorator>| undefined):
undefined { MetadataSymbolicExpression[]|undefined {
if (decorators && decorators.length) if (decorators && decorators.length)
return decorators.map(decorator => objFromDecorator(decorator)); return decorators.map(decorator => objFromDecorator(decorator));
return undefined; return undefined;

View File

@ -600,7 +600,8 @@ class AngularCompilerProgram implements Program {
private writeFile( private writeFile(
outFileName: string, outData: string, writeByteOrderMark: boolean, outFileName: string, outData: string, writeByteOrderMark: boolean,
onError?: (message: string) => void, genFile?: GeneratedFile, sourceFiles?: ts.SourceFile[]) { onError?: (message: string) => void, genFile?: GeneratedFile,
sourceFiles?: ReadonlyArray<ts.SourceFile>) {
// collect emittedLibrarySummaries // collect emittedLibrarySummaries
let baseFile: ts.SourceFile|undefined; let baseFile: ts.SourceFile|undefined;
if (genFile) { if (genFile) {
@ -647,7 +648,8 @@ class AngularCompilerProgram implements Program {
if (baseFile) { if (baseFile) {
sourceFiles = sourceFiles ? [...sourceFiles, baseFile] : [baseFile]; sourceFiles = sourceFiles ? [...sourceFiles, baseFile] : [baseFile];
} }
this.host.writeFile(outFileName, outData, writeByteOrderMark, onError, sourceFiles); // TODO: remove any when TS 2.4 support is removed.
this.host.writeFile(outFileName, outData, writeByteOrderMark, onError, sourceFiles as any);
} }
} }

View File

@ -179,7 +179,13 @@ export function create(info: any /* ts.server.PluginCreateInfo */): ts.LanguageS
} }
function completionToEntry(c: Completion): ts.CompletionEntry { function completionToEntry(c: Completion): ts.CompletionEntry {
return {kind: c.kind, name: c.name, sortText: c.sort, kindModifiers: ''}; return {
// TODO: remove any and fix type error.
kind: c.kind as any,
name: c.name,
sortText: c.sort,
kindModifiers: ''
};
} }
function diagnosticToDiagnostic(d: Diagnostic, file: ts.SourceFile): ts.Diagnostic { function diagnosticToDiagnostic(d: Diagnostic, file: ts.SourceFile): ts.Diagnostic {
@ -294,9 +300,10 @@ export function create(info: any /* ts.server.PluginCreateInfo */): ts.LanguageS
fileName: loc.fileName, fileName: loc.fileName,
textSpan: {start: loc.span.start, length: loc.span.end - loc.span.start}, textSpan: {start: loc.span.start, length: loc.span.end - loc.span.start},
name: '', name: '',
kind: 'definition', // TODO: remove any and fix type error.
kind: 'definition' as any,
containerName: loc.fileName, containerName: loc.fileName,
containerKind: 'file' containerKind: 'file' as any,
}); });
} }
} }