From ef91221cfdf71ec58065d68f8b3b1ca60990a466 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Sun, 18 Apr 2021 17:47:59 -0700 Subject: [PATCH] fix(typescript): handle .tsx inputs to angular 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