Elide bare side-effect imports in JS declaration emit#3624
Draft
Elide bare side-effect imports in JS declaration emit#3624
Conversation
Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/4e98096b-8f7e-4e0f-8c5e-7aeca971e2d2 Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix baselines export reordering and ESM side-effect import
Elide bare side-effect imports in JS declaration emit
Apr 27, 2026
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.
The declaration transformer was preserving bare side-effect imports (e.g.
import "fs";) in.d.tsoutput for JS source files. Strada's JS declaration path synthesizes declarations symbolically viaresolver.getDeclarationStatementsForSourceFileand therefore never emits these — per the issue discussion, the agreed behavior is to keep eliding them so side-effect imports remain scoped to runtime emit only.Changes
internal/transformers/declarations/transform.go— IntransformImportDeclaration, returnnilforImportClause == nilwhen the current source file is JS:TS source files retain the existing behavior of preserving bare side-effect imports.
Baselines — Updated to reflect the elision and converge with Strada:
nodeModulesAllowJsExportAssignment(module=node16/18/20/nodenext):file.d.tsnow emitsexport {};(synthesized for moduleness) instead ofimport "fs";.jsDeclarationsExportForms/jsDeclarationsExportFormsErr(target=es2015): bareimport "./xxx"lines removed from aggregating JS files.The
export = areordering noted in the issue was already produced by current emit and is acknowledged in the thread as preferable (closer to original source); only the.jsbaselines needed refreshing for it.