Skip to content

runTsc: tsc -b declaration emit crashes with "Extension .xxx is unsupported" for stripped extraSupportedExtensionsΒ #312

Description

@NullVoxPopuli

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions