Repository navigation
fix: improve string module specifiers support - #18504
Merged
Merged
Conversation
JLHwung
force-pushed
the
fix-string-module-specifiers
branch
from
November 3, 2026 15:23
d32aa77 to
d4e5147
Compare
|
commit: |
JLHwung
force-pushed
the
fix-string-module-specifiers
branch
from
November 4, 2026 00:21
d4e5147 to
fbe60f2
Compare
Collaborator
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/63122 |
nicolo-ribaudo
approved these changes
Nov 10, 2026
JLHwung
commented
Nov 10, 2026
`import { "default" as a }` and `export { a as "default" }` are equivalent
to their identifier forms, but only the identifier was compared.
Assisted-by: Claude Opus 5.5
`import { "createElement" as h } from "react"` was not recognized as a
reference to `createElement`, so for example
`transform-react-pure-annotations` did not annotate calls to `h`.
Assisted-by: Claude Opus 5.5
With JSX preserved, `import { "a b" as Foo } from "m"; <Foo />` rewrites
`Foo` to `_m["a b"]`, which has no JSX member expression form. Building one
crashed with `Property name expected type of string but got undefined`.
The same happened to any JSX tag with lazy imports, as `_m().Foo` has no
JSX form either. Throw a code frame error asking to transform JSX instead.
Assisted-by: Claude Opus 5.5
`parseTypeOnlyImportSpecifier` and `parseTypeOnlyExportSpecifier` only looked
for an identifier after `type`, even if the export branches then called
`parseModuleExportName`, so these were rejected with "Unexpected token":
export { type "a" } from "m";
export { type "a" as b } from "m";
import { type "a" as b } from "m";
export { type as as "a" } from "m";
Also `export { type as "a" }`, which is valid JavaScript exporting a binding
named `type`, could not be parsed with the `typescript` plugin.
Assisted-by: Claude Opus 5.5
JLHwung
force-pushed
the
fix-string-module-specifiers
branch
from
November 10, 2026 14:05
72b4732 to
23a6011
Compare
The "Did you mean" hint for a string local name without `from` dropped
the `type` modifier, so `export { type "a" }` and `export type { "a" }`
both suggested `export { 'a' as 'a' } from 'some-module'`, which is a
value export. Now they suggest `export { type 'a' as 'a' } from ...` and
`export type { 'a' as 'a' } from ...` respectively.
Assisted-by: Claude Opus 5.5
JLHwung
force-pushed
the
fix-string-module-specifiers
branch
from
November 10, 2026 14:23
23a6011 to
20f325a
Compare
Collaborator
|
Backported to 7.x in #18574. |
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.
As a follow-up to #18498, in this PR we implemented the following fixes related to string module specifiers:
t.isSpecifierDefaultnow recognizes "default"referencesImportnow matches string import names, so transform-react-pure-annotations now annotates import{"createElement" as h}type "a"specifiers andexport { type X as "a" } from "foo". Both forms already supported bytsc.