Summary
When a consumer passes extraSupportedExtensions together with extraExtensionsToRemove (e.g. glint registers .gts/.gjs and strips them so foo.gts emits foo.d.ts), tsc -b / build mode can abort during declaration emit with:
Error: Debug Failure. Extension .gts is unsupported:: FileName:: .../foo.gts
Cause
transformTscContent already teaches tsc about the extra extensions in several places β supportedTSExtensions / supportedJSExtensions / allSupportedExtensions, changeExtension, and extensionsToRemove β but not tryGetJSExtensionForFile, which maps a source file to the JS extension it emits (.ts β .js, .tsx β .jsx/.js, β¦).
In build mode, declaration emit synthesizes module specifiers for imported symbols. When the preferred ending is "js" (e.g. a sibling ./x.js import is preserved in the emitted .d.ts) and the target is one of these extra-extension files, tsc calls getJSExtensionForFile, which falls through to Debug.fail("Extension .xxx is unsupported") and aborts the whole build.
--noEmit checking does not compute those specifiers, so this only surfaces under tsc -b.
Notes
Fix
One addition to transformTscContent, keyed off extraExtensionsToRemove, mapping those extensions to .js in tryGetJSExtensionForFile (same wrapper style as the existing changeExtension patch). PR incoming.
Summary
When a consumer passes
extraSupportedExtensionstogether withextraExtensionsToRemove(e.g. glint registers.gts/.gjsand strips them sofoo.gtsemitsfoo.d.ts),tsc -b/ build mode can abort during declaration emit with:Cause
transformTscContentalready teaches tsc about the extra extensions in several places βsupportedTSExtensions/supportedJSExtensions/allSupportedExtensions,changeExtension, andextensionsToRemoveβ but nottryGetJSExtensionForFile, which maps a source file to the JS extension it emits (.tsβ.js,.tsxβ.jsx/.js, β¦).In build mode, declaration emit synthesizes module specifiers for imported symbols. When the preferred ending is
"js"(e.g. a sibling./x.jsimport is preserved in the emitted.d.ts) and the target is one of these extra-extension files, tsc callsgetJSExtensionForFile, which falls through toDebug.fail("Extension .xxx is unsupported")and aborts the whole build.--noEmitchecking does not compute those specifiers, so this only surfaces undertsc -b.Notes
extraExtensionsToRemovebehave like.tsβ.js. Kept extensions (e.g. Vue's.vue, which appends tofoo.vue.d.ts) take a different emit path and don't hit this.tsc -b/ember-tsc --buildcrash on.gtsdeclaration emit ("Extension .gts is unsupported")Β typed-ember/glint#1157Fix
One addition to
transformTscContent, keyed offextraExtensionsToRemove, mapping those extensions to.jsintryGetJSExtensionForFile(same wrapper style as the existingchangeExtensionpatch). PR incoming.