Fix declaration maps for export assignment expressions - #64460
Open
Mariana Castro (maricastroc) wants to merge 2 commits into
Open
Mariana Castro (maricastroc) wants to merge 2 commits into
Mariana Castro (maricastroc) wants to merge 2 commits into
Conversation
Copilot started reviewing on behalf of
Mariana Castro (maricastroc)
September 26, 2026 01:59
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The modified class-expression and function-like branches lack declaration-map regression coverage.
Review effort: Balanced
Findings: 1
What changed in this PR
Fixes declaration-map mappings for synthesized export assignments by preserving source-map ranges.
Changes:
- Assigns source-map ranges across export-assignment transformation branches.
- Adds regression coverage and updates declaration-map baselines.
| File | Description |
|---|---|
tsc/internal/transformers/declarations/transform.go |
Preserves export-assignment source ranges. |
tsc/testdata/tests/cases/compiler/declarationMapsExportAssignmentExpression.ts |
Adds expression export tests. |
tsc/testdata/baselines/reference/compiler/declarationMapsExportAssignmentExpression.types |
Adds type baseline. |
tsc/testdata/baselines/reference/compiler/declarationMapsExportAssignmentExpression.symbols |
Adds symbol baseline. |
tsc/testdata/baselines/reference/compiler/declarationMapsExportAssignmentExpression.sourcemap.txt |
Adds readable map baseline. |
tsc/testdata/baselines/reference/compiler/declarationMapsExportAssignmentExpression.js.map |
Adds declaration-map output. |
tsc/testdata/baselines/reference/compiler/declarationMapsExportAssignmentExpression.js |
Adds emit baseline. |
tsc/testdata/baselines/reference/compiler/declarationMaps.sourcemap.txt |
Updates identifier mapping baseline. |
tsc/testdata/baselines/reference/compiler/declarationMaps.js.map |
Updates serialized declaration map. |
Files not reviewed (1)
- tsc/testdata/baselines/reference/compiler/declarationMapsExportAssignmentExpression.js: Generated file
Cover the class-expression and function-like branches of
transformExportAssignment with `export = class {}` and an
`export default` arrow function, so their synthesized export
assignment mappings are baselined.
Author
|
@microsoft-github-policy-service agree |
This branch has not been deployed
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 #64433
Analysis
For
export default <expr>/export = <expr>with a non-identifier expression, declaration emit produces a synthesizeddeclare const _default: ...;followed byexport default _default;(orexport = _default;).transformExportAssignmentbuilds that export assignment withNewExportAssignment, so the synthesized export assignments were missing source-map ranges and the printer emitted no mapping for them. Before the logic moved into the sharedtransformExportAssignmentin microsoft/typescript-go#3388, it usedUpdateExportAssignment(input, ...), which kept the range.TypeScript 6.0 emits
"mappings":";;;;AAEA,wBAAwB"for this file; before this change the.d.ts.maphad"mappings":"". The identifier form (export = m2;indeclarationMaps) also lost its statement-level start/end mappings.Fix
Assign the original statement's source-map range to each synthesized export assignment in
transformExportAssignmentviaEmitContext().AssignSourceMapRange(exportAssignment, input). Only the source-map range is copied, notLocor the original node, so declaration output is unchanged. CopyingLocwas considered, but it reattaches source comments to the synthesized node (e.g.export default /** @type {P} */ _default;indeclarationEmitCastReusesTypeNode4).declarationMapsExportAssignmentExpression.ts, covering a non-identifierexport defaultand the sharedexport =path; the mappings now match TypeScript 6.0.declarationMapssource map baselines;declarationMaps.sourcemap.txtnow matches the TypeScript 6.0 baseline..d.tsoutput changed; only.js.mapand.sourcemap.txtbaselines differ.Copilot Checklist
I successfully ran the applicable command at the end of my session, and it completed without error:
npx hereby validatedid not complete cleanly. Compiler tests, lint, formatting, codegen, and extension tests passed, but each of two runs hit an unrelated flaky macOSfswatch/FSEvents test, on different subtests (TestFSEventsWatchFileDifferentCasing,TestFSEventsExpansionAliases/sharp-s). Those tests passed wheninternal/fswatchwas run on its own.npx hereby check:formatpassed.--apiis not applicable.AI disclosure (per CONTRIBUTING.md): this patch was written with Claude Code and reviewed by me before submission.