build(bazel): make resolveTypeReferenceDirectives override work with both ts 2.9 & ts 3.0 (#25581)
PR Close #25581
This commit is contained in:
parent
910381ddbd
commit
31349fde90
|
@ -19,14 +19,19 @@ export class GeneratedFactoryHostWrapper implements ts.CompilerHost {
|
|||
private delegate: ts.CompilerHost, private generator: FactoryGenerator,
|
||||
private factoryToSourceMap: Map<string, string>) {
|
||||
if (delegate.resolveTypeReferenceDirectives) {
|
||||
// Backward compatibility with TypeScript 2.9 and older since return
|
||||
// type has changed from (ts.ResolvedTypeReferenceDirective | undefined)[]
|
||||
// to ts.ResolvedTypeReferenceDirective[] in Typescript 3.0
|
||||
type ts3ResolveTypeReferenceDirectives = (names: string[], containingFile: string) =>
|
||||
ts.ResolvedTypeReferenceDirective[];
|
||||
this.resolveTypeReferenceDirectives = (names: string[], containingFile: string) =>
|
||||
delegate.resolveTypeReferenceDirectives !(names, containingFile);
|
||||
(delegate.resolveTypeReferenceDirectives as ts3ResolveTypeReferenceDirectives) !(
|
||||
names, containingFile);
|
||||
}
|
||||
}
|
||||
|
||||
resolveTypeReferenceDirectives?:
|
||||
(names: string[],
|
||||
containingFile: string) => (ts.ResolvedTypeReferenceDirective | undefined)[];
|
||||
(names: string[], containingFile: string) => ts.ResolvedTypeReferenceDirective[];
|
||||
|
||||
getSourceFile(
|
||||
fileName: string, languageVersion: ts.ScriptTarget,
|
||||
|
|
|
@ -79,8 +79,7 @@ export class TsCompilerAotCompilerTypeCheckHostAdapter implements ts.CompilerHos
|
|||
// TODO(issue/24571): remove '!'.
|
||||
getDirectories !: (path: string) => string[];
|
||||
resolveTypeReferenceDirectives?:
|
||||
(names: string[],
|
||||
containingFile: string) => (ts.ResolvedTypeReferenceDirective | undefined)[];
|
||||
(names: string[], containingFile: string) => ts.ResolvedTypeReferenceDirective[];
|
||||
directoryExists?: (directoryName: string) => boolean;
|
||||
|
||||
constructor(
|
||||
|
@ -106,8 +105,14 @@ export class TsCompilerAotCompilerTypeCheckHostAdapter implements ts.CompilerHos
|
|||
this.getDefaultLibLocation = () => context.getDefaultLibLocation !();
|
||||
}
|
||||
if (context.resolveTypeReferenceDirectives) {
|
||||
// Backward compatibility with TypeScript 2.9 and older since return
|
||||
// type has changed from (ts.ResolvedTypeReferenceDirective | undefined)[]
|
||||
// to ts.ResolvedTypeReferenceDirective[] in Typescript 3.0
|
||||
type ts3ResolveTypeReferenceDirectives = (names: string[], containingFile: string) =>
|
||||
ts.ResolvedTypeReferenceDirective[];
|
||||
this.resolveTypeReferenceDirectives = (names: string[], containingFile: string) =>
|
||||
context.resolveTypeReferenceDirectives !(names, containingFile);
|
||||
(context.resolveTypeReferenceDirectives as ts3ResolveTypeReferenceDirectives) !(
|
||||
names, containingFile);
|
||||
}
|
||||
if (context.trace) {
|
||||
this.trace = s => context.trace !(s);
|
||||
|
|
Loading…
Reference in New Issue