Amd workaround in external ts_library rules should only affect TS <= 2.8.
The underlying bug was fixed in TS 2.9 and without a change the workaround +
the fix create duplicate <amd-module> annotations.
PiperOrigin-RevId: 202527167
diff --git a/internal/tsc_wrapped/compiler_host.ts b/internal/tsc_wrapped/compiler_host.ts
index 8494077..2649be4 100644
--- a/internal/tsc_wrapped/compiler_host.ts
+++ b/internal/tsc_wrapped/compiler_host.ts
@@ -378,7 +378,12 @@
onError: ((message: string) => void) | undefined,
sourceFiles: ReadonlyArray<ts.SourceFile>): void {
// Workaround https://github.com/Microsoft/TypeScript/issues/18648
- if ((this.options.module === ts.ModuleKind.AMD ||
+ // This bug is fixed in TS 2.9
+ const version = ts.versionMajorMinor;
+ const [major, minor] = version.split('.').map(s => Number(s));
+ const workaroundNeeded = major <= 2 && minor <= 8;
+ if (workaroundNeeded &&
+ (this.options.module === ts.ModuleKind.AMD ||
this.options.module === ts.ModuleKind.UMD) &&
fileName.endsWith('.d.ts') && sourceFiles && sourceFiles.length > 0 &&
sourceFiles[0].moduleName) {