Repository navigation
Fix declaration emit crash with computed unique symbol static - #65828
Closed
Sho Takahashi / 髙橋 翔 (Ya-hari) wants to merge 3 commits into
Closed
Sho Takahashi / 髙橋 翔 (Ya-hari) wants to merge 3 commits into
Sho Takahashi / 髙橋 翔 (Ya-hari) wants to merge 3 commits into
Conversation
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
🟢 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
Author
|
Closing this as a duplicate of #65827, which was opened just before this one. Sorry for the noise! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #65744
When building the
(typeof K)[typeof key]access for a computed static member,createAccessFromSymbolChainreused the key expression from the declaring fileas 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,
keywas 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 serializedfor the emitting file.
Tests:
declarationEmitComputedUniqueSymbolStaticAccess.ts: the repro from the issue.main.d.tsnow importskey.declarationEmitComputedUniqueSymbolStaticAccess2.ts: the same type reaching afile that doesn't import
Korkey; it is emitted withimport()types.I used an AI assistant to help understand the code and draft this description;
I wrote and tested the change myself.