Skip to content

fix(generator): preserve type modifier in TSImportEqualsDeclaration - #18437

Merged
nicolo-ribaudo merged 1 commit into
babel:mainfrom
saiyam-jain-dev:fix-ts-import-equals-type-modifier
Oct 28, 2026
Merged

nicolo-ribaudo merged 1 commit into
babel:mainfrom
saiyam-jain-dev:fix-ts-import-equals-type-modifier

Conversation

@saiyam-jain-dev

@saiyam-jain-dev saiyam-jain-dev commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Q A
Fixed Issues? Fixes #18357
Patch: Bug Fix? Yes
Major: Breaking Change? No
Minor: New Feature? No
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes? No
Need backport? 7.x
License MIT

When printing a TSImportEqualsDeclaration node, packages/babel-generator/src/generators/typescript.ts was not checking node.importKind. When importKind === "type", the generator omitted type, printing import a = require("a") instead of import type a = require("a").

This change prints the type modifier when node.importKind === "type", preserving it for import type a = require("a") and export import type a = require("a").

@babel-bot

Copy link
Copy Markdown
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/62648

@pkg-pr-new

pkg-pr-new Bot commented Oct 28, 2026

Copy link
Copy Markdown
@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: generator labels Oct 28, 2026

@JLHwung JLHwung left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks.

@nicolo-ribaudo
nicolo-ribaudo merged commit 1db553f into babel:main Oct 28, 2026
72 of 73 checks passed
@babel-bot

Copy link
Copy Markdown
Collaborator

Backported to 7.x in #18454.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentscan:mixed-signals pkg: generator PR: Bug Fix 🐛 A type of pull request used for our changelog categories

4 participants