Skip to content

Commit 901df38

Browse files
authored
fix(typescript): handle .tsx inputs to angular (#2613)
fixes #2542
1 parent ee9e2a2 commit 901df38

File tree

1 file changed

+7
-3
lines changed
  • third_party/github.com/bazelbuild/rules_typescript/internal/tsc_wrapped

1 file changed

+7
-3
lines changed

third_party/github.com/bazelbuild/rules_typescript/internal/tsc_wrapped/tsc_wrapped.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,13 @@ export function createProgramAndEmit(
454454
if (!/\.ng(factory|summary)\.ts$/.test(sf.fileName)) {
455455
return false;
456456
}
457-
return isCompilationTarget(bazelOpts, {
458-
fileName: sf.fileName.slice(0, /*'.ngfactory|ngsummary.ts'.length*/ -13) + '.ts'
459-
} as ts.SourceFile);
457+
const base = sf.fileName.slice(0, /*'.ngfactory|ngsummary.ts'.length*/ -13);
458+
// It's possible a file was named ngsummary.ts or ngfactory.ts but *not* synthetic
459+
// So verify that base.ts or base.tsx was originally part of the compilation
460+
const tsCandidate = {fileName: `${base}.ts`} as ts.SourceFile;
461+
const tsxCandidate = {fileName: `${base}.tsx`} as ts.SourceFile;
462+
return isCompilationTarget(bazelOpts, tsCandidate) ||
463+
isCompilationTarget(bazelOpts, tsxCandidate);
460464
}
461465

462466
// If the Angular plugin is in use, this list of files to emit should exclude

0 commit comments

Comments
 (0)