From 901df3868e3ceda177d3ed181205e8456a5592ea Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Mon, 19 Apr 2021 16:55:54 -0700 Subject: [PATCH] fix(typescript): handle .tsx inputs to angular (#2613) fixes #2542 --- .../internal/tsc_wrapped/tsc_wrapped.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/third_party/github.com/bazelbuild/rules_typescript/internal/tsc_wrapped/tsc_wrapped.ts b/third_party/github.com/bazelbuild/rules_typescript/internal/tsc_wrapped/tsc_wrapped.ts index a18c04393f..79160f284c 100644 --- a/third_party/github.com/bazelbuild/rules_typescript/internal/tsc_wrapped/tsc_wrapped.ts +++ b/third_party/github.com/bazelbuild/rules_typescript/internal/tsc_wrapped/tsc_wrapped.ts @@ -454,9 +454,13 @@ export function createProgramAndEmit( if (!/\.ng(factory|summary)\.ts$/.test(sf.fileName)) { return false; } - return isCompilationTarget(bazelOpts, { - fileName: sf.fileName.slice(0, /*'.ngfactory|ngsummary.ts'.length*/ -13) + '.ts' - } as ts.SourceFile); + const base = sf.fileName.slice(0, /*'.ngfactory|ngsummary.ts'.length*/ -13); + // It's possible a file was named ngsummary.ts or ngfactory.ts but *not* synthetic + // So verify that base.ts or base.tsx was originally part of the compilation + const tsCandidate = {fileName: `${base}.ts`} as ts.SourceFile; + const tsxCandidate = {fileName: `${base}.tsx`} as ts.SourceFile; + return isCompilationTarget(bazelOpts, tsCandidate) || + isCompilationTarget(bazelOpts, tsxCandidate); } // If the Angular plugin is in use, this list of files to emit should exclude