Repository navigation
Fix invalid export default namespace in declaration emit for expandos on JS export default class - #65733
Open
Ryan Cavanaugh (RyanCavanaugh) wants to merge 4 commits into
Open
Fix invalid export default namespace in declaration emit for expandos on JS export default class#65733Ryan Cavanaugh (RyanCavanaugh) wants to merge 4 commits into
export default namespace in declaration emit for expandos on JS export default class#65733Ryan Cavanaugh (RyanCavanaugh) wants to merge 4 commits into
Conversation
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
… emit Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…port default` Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Ryan Cavanaugh (RyanCavanaugh)
marked this pull request as ready for review
November 30, 2026 20:10
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues blocking approval.
No open issues 🎉
What changed in this PR
Fixes #65731 by correcting declaration emit for JavaScript default-exported classes with expando properties, preventing invalid export default namespace syntax in generated .d.ts files.
Changes:
- Emits the class with
declareand a separate default export while preserving synthesized base declarations. - Adds regression coverage for plain expandos, helper aliases, and expression-based inheritance.
- Adds declaration-output, type, and symbol baselines.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/declarationEmitJsDefaultExportClassExpando.ts |
Tests three expando scenarios and their imports. |
tsc/testdata/baselines/reference/compiler/declarationEmitJsDefaultExportClassExpando.types |
Records inferred types for the regression cases. |
tsc/testdata/baselines/reference/compiler/declarationEmitJsDefaultExportClassExpando.symbols |
Records symbol bindings for the regression cases. |
tsc/testdata/baselines/reference/compiler/declarationEmitJsDefaultExportClassExpando.js |
Records corrected declaration output. |
tsc/internal/transformers/declarations/transform.go |
Handles default-exported class expandos with valid declaration modifiers. |
Review effort: Balanced
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.
In JS, a property assigned to a default-exported class (an expando) made declaration emit produce
export default namespace X, which is a syntax error. Because it is a syntax error,skipLibCheckdoesn't suppress it, so every consumer of such a.d.tsfails to type-check. This regressed from 6.0.Before:
After:
Cause
createFullExpandoBlockcopies the host's modifiers onto the synthesized namespace.transformExpandoHostalready handles default-exported function hosts: it emitsdeclare function fplusexport default f;. Class hosts went through the genericelsebranch, so they keptexport default, and the namespace got a copy of it.Change (
transformExpandoHost)defaultExport && IsClassDeclaration. It transforms the class as usual, then replaces the class's modifiers with the computeddeclaremodifiers.X_basevariable emitted forextends <expression>is kept.export default X;, sets the external-module and scope-marker flags, and refresheslateStatementReplacementMap.reportExpandoFunctionErrorsis still skipped for classes, as before. Its isolatedDeclarations message is specific to functions.Test
declarationEmitJsDefaultExportClassExpando.tscovers:export { helper };extends mixin(Root)host.The first commit's baseline records the bug in the
DtsFileErrorssection; the fix commit removes it. No other baselines change.export default namespace) for expando members of a JSexport default class#65731