Skip to content

fix(emit): normalize extra-extension declaration paths (issue #63) - #68

Closed
johnsoncodehk with Copilot wants to merge 2 commits into
masterfrom
copilot/vue-tsc-fix-declaration-emit
Closed

fix(emit): normalize extra-extension declaration paths (issue #63)#68
johnsoncodehk with Copilot wants to merge 2 commits into
masterfrom
copilot/vue-tsc-fix-declaration-emit

Conversation

Copilot AI commented Aug 22, 2026

Copy link
Copy Markdown

vue-tsc declaration emit produces Button.vue.d.vue.ts instead of Button.vue.d.ts when backed by TNB. tsgo uses the {name}.d.{ext}.ts convention for allowArbitraryExtensions sources, but the host (stock TypeScript + Volar) expects {name}.d.ts.

Changes

  • patches/typescript/overlay/src/compiler/tsgoChecker.ts — adds fixExtraExtDeclarationPath and applies it in the Program.emit output loop. For each registered extra file extension, strips the redundant .{ext} from .d.{ext}.ts output paths before handing the name to the host's writeFile:

    Button.vue.d.vue.ts  →  Button.vue.d.ts
    

    Keyed on programCtx.pendingExtraFileExtensions — no framework name literals; covers any registered extra extension (.vue, .svelte, .astro, …).

  • tools/triage-vue-tsc-decl-emit.mjs — new witness: registers .vue via supportedTSExtensionsFlat, runs createProgram + emit on a minimal .vue fixture, asserts output is Button.vue.d.ts not Button.vue.d.vue.ts. Added to wg5 in ci-witness-groups.mjs (TOTAL 72 → 73).

tsgo emits `Button.vue.d.vue.ts` for .vue source files with
allowArbitraryExtensions, but the host convention (stock TypeScript +
Volar) is `Button.vue.d.ts`.

Add `fixExtraExtDeclarationPath` to strip the redundant `.{ext}` from
`.d.{ext}.ts` declaration output paths in Program.emit, keyed on the
registered extraFileExtensions — no framework literals.

Add witness `triage-vue-tsc-decl-emit` to gate the fix in CI (TOTAL 72→73).

Co-authored-by: johnsoncodehk <16279759+johnsoncodehk@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix vue-tsc declaration emit extension issue fix(emit): normalize extra-extension declaration paths (issue #63) Aug 22, 2026
Copilot AI requested a review from johnsoncodehk August 22, 2026 04:04
@johnsoncodehk

Copy link
Copy Markdown
Owner

Closing this — the root cause is an upstream tsgo bug, not a bridge divergence, so this would be a stopgap that papers over the engine rather than fixing it.

GetDeclarationEmitExtensionForPath in typescript-go/internal/tspath/extension.go (pristine — no TNB patch touches it) puts the resolution convention .d.<ext>.ts into the emit function:

default:
    ext := GetAnyExtensionFromPath(path, nil, false)
    if ext != "" {
        return ".d" + ext + ".ts"  // Button.vue → ".d.vue.ts"
    }
    return ExtensionDts

Stock's emitter default is .d.ts. The real fix belongs upstream: change that default to .d.ts (keeping the .json.d.json.ts case). I'll file the upstream issue.

fixExtraExtDeclarationPath is a clean mechanism (keys on registered extra extensions, no framework literals), but it's still a host-boundary workaround for an upstream bug. If we want it as a stopgap, AGENTS.md requires a README tsgo-behavior-changes entry, a Ledger() annotation, and the upstream issue link — none of which is present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vue-tsc emits Button.vue.d.vue.ts instead of Button.vue.d.ts

2 participants