Skip to content

fix(types): visit decorators of TSParameterProperty - #18380

Merged
nicolo-ribaudo merged 1 commit into
babel:mainfrom
JLHwung:fix-types-ts-parameter-property-decorators
Oct 21, 2026
Merged

nicolo-ribaudo merged 1 commit into
babel:mainfrom
JLHwung:fix-types-ts-parameter-property-decorators

Conversation

@JLHwung

@JLHwung JLHwung commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor
Q                       A
Fixed Issues? Babel-traverse does not visit the decorators property of the TSParameterProperty
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
Need backport? 7.x
License MIT

This PR is sprung off from #18372, it fixed an issue reported during the review session with Claude: The decorators of a TSParameterProperty, e.g. @dec in constructor(@dec private x) {}, were not in its visitor keys, so they were not traversed: their references were not registered in the scope, and transform-typescript removed an import that is only used by them. @babel/eslint-parser, which uses the same visitor keys, did not convert them either, which led to an AST different from typescript-estree.

This is the same fix as #8738 did for Identifier and AssignmentPattern. The builder keys are pinned to parameter, so the tsParameterProperty builder is unchanged.

Assisted-by: Claude Opus 5.5 [email protected]

The decorators of a TSParameterProperty, e.g. `@dec` in
`constructor(@dec private x) {}`, were not in its visitor keys, so they
were not traversed: their references were not registered in the scope,
and transform-typescript removed an import that is only used by them.
@babel/eslint-parser, which uses the same visitor keys, did not convert
them either, which led to an AST different from typescript-estree.

This is the same fix as babel#8738 did for Identifier and AssignmentPattern.
The builder keys are pinned to `parameter`, so the
`tsParameterProperty` builder is unchanged.

Assisted-by: Claude Opus 5.5 <[email protected]>
@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: types labels Oct 21, 2026
@babel-bot

Copy link
Copy Markdown
Collaborator

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

@pkg-pr-new

pkg-pr-new Bot commented Oct 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: 5698dd4

@nicolo-ribaudo
nicolo-ribaudo merged commit c897d1e into babel:main Oct 21, 2026
@nicolo-ribaudo
nicolo-ribaudo deleted the fix-types-ts-parameter-property-decorators branch October 21, 2026 14:52
@babel-bot

Copy link
Copy Markdown
Collaborator

Backported to 7.x in #18391.

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

Labels

pkg: types PR: Bug Fix 🐛 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants