Skip to content

Fix declaration emit crash with computed unique symbol static - #65828

Closed
Sho Takahashi / 髙橋 翔 (Ya-hari) wants to merge 3 commits into
microsoft:mainfrom
Ya-hari:fix-65744
Closed

Sho Takahashi / 髙橋 翔 (Ya-hari) wants to merge 3 commits into
microsoft:mainfrom
Ya-hari:fix-65744

Conversation

@Ya-hari

Copy link
Copy Markdown

Fixes #65744

When building the (typeof K)[typeof key] access for a computed static member,
createAccessFromSymbolChain reused the key expression from the declaring file
as the type query's name. The printer then asserted because that identifier
belongs to a different source file than the one being emitted (and in 6.0, key
was never imported).

This change resolves the key's symbol and builds a fresh reference with
symbolToTypeNode, so the symbol is tracked and the reference is serialized
for the emitting file.

Tests:

  • declarationEmitComputedUniqueSymbolStaticAccess.ts: the repro from the issue.
    main.d.ts now imports key.
  • declarationEmitComputedUniqueSymbolStaticAccess2.ts: the same type reaching a
    file that doesn't import K or key; it is emitted with import() types.

I used an AI assistant to help understand the code and draft this description;
I wrote and tested the change myself.

Copilot AI balanced review requested due to automatic review settings December 5, 2026 21:44
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Dec 5, 2026
@typescript-automation typescript-automation Bot added For Backlog Bug PRs that fix a backlog bug labels Dec 5, 2026
@Ya-hari

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block approval of the computed-key declaration emit change.

No open issues 🎉

What changed in this PR

Fixes #65744 by creating fresh, tracked symbol references during declaration emit, avoiding a cross-file printer crash and missing key imports.

Changes:

  • Resolves computed static-member keys through symbolToTypeNode.
  • Adds regression tests for direct imports and indirect references using import() types.
  • Records declaration, JavaScript, type, and symbol baselines.
File Description
tsc/​internal/​checker/​nodebuilderimpl.go Builds fresh references for computed keys.
tsc/​testdata/​tests/​cases/​compiler/​declarationEmitComputedUniqueSymbolStaticAccess.ts Tests direct-import declaration emit.
tsc/​testdata/​tests/​cases/​compiler/​declarationEmitComputedUniqueSymbolStaticAccess2.ts Tests indirect references without local imports.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitComputedUniqueSymbolStaticAccess.js Captures emit with the retained key import.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitComputedUniqueSymbolStaticAccess.symbols Records direct-case symbol resolution.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitComputedUniqueSymbolStaticAccess.types Records direct-case inferred types.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitComputedUniqueSymbolStaticAccess2.js Captures emit using import() types.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitComputedUniqueSymbolStaticAccess2.symbols Records indirect-case symbol resolution.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitComputedUniqueSymbolStaticAccess2.types Records indirect-case inferred types.

Review effort: Balanced

@Ya-hari

Copy link
Copy Markdown
Author

Closing this as a duplicate of #65827, which was opened just before this one. Sorry for the noise!

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

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Declaration emit crashes on an imported class indexed by a computed unique-symbol static

2 participants