From 42f8e6ed6199cac44a1578167ff61cc87e970850 Mon Sep 17 00:00:00 2001 From: Jon Wallsten Date: Thu, 20 Sep 2018 14:09:44 +0200 Subject: [PATCH] fix(compiler-cli): Temp fix in program.ts issue (#22524) Compiling a project with duplicated sub dependencies causes 'Host should not return a redirect source file from `getSourceFile`' error to be shown. This is fixed by not returning the redirected file, but rather the target of the redirect. Closes https://github.com/angular/angular/issues/22524 --- packages/compiler-cli/src/transformers/program.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/compiler-cli/src/transformers/program.ts b/packages/compiler-cli/src/transformers/program.ts index 9e028138324ca..e837301ac0ff8 100644 --- a/packages/compiler-cli/src/transformers/program.ts +++ b/packages/compiler-cli/src/transformers/program.ts @@ -693,6 +693,10 @@ class AngularCompilerProgram implements Program { const tsFiles: string[] = []; tmpProgram.getSourceFiles().forEach(sf => { if (this.hostAdapter.isSourceFile(sf.fileName)) { + // Temporary fix for https://github.com/angular/angular/issues/22524 + // Typescript has internal notion of "redirect source files" + // Do not return the redirected file, but rather the target of the redirect. + // redirectInfo is an internal property on the SourceFile interface, hence the (as any) if ((sf as any)['redirectInfo']) { sf = (sf as any)['redirectInfo'].redirectTarget; }