build: TypeScript 3.6 compatibility. (#32908)
This PR updates Angular to compile with TypeScript 3.6 while retaining compatibility with TS3.5. We achieve this by inserting several `as any` casts for compatiblity around `ts.CompilerHost` APIs. PR Close #32908
This commit is contained in:
@ -180,8 +180,11 @@ export class CommonJsReflectionHost extends Esm5ReflectionHost {
|
||||
private resolveModuleName(moduleName: string, containingFile: ts.SourceFile): ts.SourceFile
|
||||
|undefined {
|
||||
if (this.compilerHost.resolveModuleNames) {
|
||||
const moduleInfo =
|
||||
this.compilerHost.resolveModuleNames([moduleName], containingFile.fileName)[0];
|
||||
// FIXME: remove the "as any" cast once on TS3.6.
|
||||
const moduleInfo = (this.compilerHost as any)
|
||||
.resolveModuleNames(
|
||||
[moduleName], containingFile.fileName, undefined, undefined,
|
||||
this.program.getCompilerOptions())[0];
|
||||
return moduleInfo && this.program.getSourceFile(absoluteFrom(moduleInfo.resolvedFileName));
|
||||
} else {
|
||||
const moduleInfo = ts.resolveModuleName(
|
||||
|
@ -158,8 +158,11 @@ export class UmdReflectionHost extends Esm5ReflectionHost {
|
||||
private resolveModuleName(moduleName: string, containingFile: ts.SourceFile): ts.SourceFile
|
||||
|undefined {
|
||||
if (this.compilerHost.resolveModuleNames) {
|
||||
const moduleInfo =
|
||||
this.compilerHost.resolveModuleNames([moduleName], containingFile.fileName)[0];
|
||||
// FIXME: remove the "as any" cast once on TS3.6.
|
||||
const moduleInfo = (this.compilerHost as any)
|
||||
.resolveModuleNames(
|
||||
[moduleName], containingFile.fileName, undefined, undefined,
|
||||
this.program.getCompilerOptions())[0];
|
||||
return moduleInfo && this.program.getSourceFile(absoluteFrom(moduleInfo.resolvedFileName));
|
||||
} else {
|
||||
const moduleInfo = ts.resolveModuleName(
|
||||
@ -281,4 +284,4 @@ function findNamespaceOfIdentifier(id: ts.Identifier): ts.Identifier|null {
|
||||
|
||||
export function stripParentheses(node: ts.Node): ts.Node {
|
||||
return ts.isParenthesizedExpression(node) ? node.expression : node;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user