Skip to content

Remove isElisionBlocked#2673

Open
jakebailey wants to merge 2 commits intomainfrom
jabaile/remove-isElisionBlocked
Open

Remove isElisionBlocked#2673
jakebailey wants to merge 2 commits intomainfrom
jabaile/remove-isElisionBlocked

Conversation

@jakebailey
Copy link
Member

Fixes #2636

Alternative to #2646 (which is this PR but for one call)

Reading the original code's comment:

    /**
     * Determines whether import/export elision is blocked for this statement.
     *
     * @description
     * We generally block import/export elision if the statement was modified by a `before` custom
     * transform, although we will continue to allow it if the statement hasn't replaced a node of a different kind and
     * as long as the local bindings for the declarations are unchanged.
     */

The purpose of this function is to not elide an import if it had been touched by a custom before transformer.

In Strada, this was fine. The ts transformer went first and did everything under the sun; import elision, type removal, etc.

But now, we split things up. The type eraser runs before the import elider, and the eraser can touch imports (and even elide them itself). This puts us directly in the path of isElisionBlocked.

We don't have before transformers, and it's nontrivial to attempt to mush these transformers back together again.

I think it's probably okay to just delete isElisionBlocked and address this later if we find it to be a problem.

Funnily, if you delete isElisionBlocked from Strada, nothing breaks!

Copilot AI review requested due to automatic review settings February 4, 2026 04:34
Copy link
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

This PR removes the isElisionBlocked function from the import elision transformer. The function previously prevented import/export elision for statements modified by custom before transformers. Since the codebase no longer uses before transformers and the type eraser (which can touch imports) now runs before the import elider, this check is obsolete and was blocking legitimate elision.

Changes:

  • Removed the isElisionBlocked function and all its logic
  • Simplified import/export elision code paths by removing conditional blocking checks
  • Updated test baselines to reflect that type-only imports are now properly elided

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.

File Description
internal/transformers/tstransforms/importelision.go Removed isElisionBlocked function and simplified elision logic by removing blocking checks
testdata/baselines/reference/submodule/conformance/nodeModulesImportModeDeclarationEmitErrors1(module=*).js Updated baselines showing type-only imports are now properly elided across different module modes
testdata/baselines/reference/submodule/conformance/nodeModulesImportAttributesModeDeclarationEmitErrors(module=*).js Updated baselines showing type-only imports are now properly elided for import attributes syntax
testdata/baselines/reference/submodule/conformance/importSpecifiers1.js Updated baseline showing a type-only import is now elided instead of preserved

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.

tsgo emits a require statement when a value is imported without the type keyword but only used in type-level positions

1 participant