Skip to content

Fix dts porting bug#3350

Open
jakebailey wants to merge 1 commit intomainfrom
jabaile/dts-fixes-typo
Open

Fix dts porting bug#3350
jakebailey wants to merge 1 commit intomainfrom
jabaile/dts-fixes-typo

Conversation

@jakebailey
Copy link
Copy Markdown
Member

Noticed this porting bug; the syntax list is not going to be an external module indicator. However, it does not seem to matter.

Copilot AI review requested due to automatic review settings April 6, 2026 16:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a declarations (.d.ts) emit porting issue in the declaration transformer where a SyntaxList replacement was incorrectly checked as an external-module indicator, instead of checking the list elements.

Changes:

  • Correct external module indicator detection for late-painted statement replacements that return a SyntaxList by checking each child statement node.

Comment on lines 362 to 370
if replacement.Kind == ast.KindSyntaxList {
if !tx.needsScopeFixMarker || !tx.resultHasExternalModuleIndicator {
for _, elem := range replacement.AsSyntaxList().Children {
if needsScopeMarker(elem) {
tx.needsScopeFixMarker = true
}
if ast.IsSourceFile(statement.Parent) && ast.IsExternalModuleIndicator(replacement) {
if ast.IsSourceFile(statement.Parent) && ast.IsExternalModuleIndicator(elem) {
tx.resultHasExternalModuleIndicator = true
}
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

This fixes external-module-indicator detection for SyntaxList replacements, but there’s no regression test covering the SyntaxList path (where a transformed statement expands into multiple statements including an import/export). Please add a minimal compiler baseline test that triggers a late-painted statement replacement returning a SyntaxList with an external module indicator, and asserts we don’t incorrectly inject the empty export {} marker due to resultHasExternalModuleIndicator staying false.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, though given this is syntax list expansion, maybe this was just for JS dts emit or something

@jakebailey jakebailey requested a review from weswigham April 6, 2026 18:03
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.

2 participants