Skip to content

fix(generator): print override modifier of TSParameterProperty - #18506

Merged
nicolo-ribaudo merged 1 commit into
babel:mainfrom
JLHwung:fix-generator-ts-parameter-property-override
Nov 4, 2026
Merged

nicolo-ribaudo merged 1 commit into
babel:mainfrom
JLHwung:fix-generator-ts-parameter-property-override

Conversation

@JLHwung

@JLHwung JLHwung commented Nov 3, 2026

Copy link
Copy Markdown
Contributor
Q                       A
Fixed Issues? Babel generator does not print the override modifier of the TSParameterProperty: class C { constructor(override foo: string) {} }.
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 issue is detected by Claude Fable and the fix is attached.

@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: generator 7.x: needs backport labels Nov 3, 2026
@pkg-pr-new

pkg-pr-new Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

commit: 0ebeadb

`class C { constructor(override foo: string) {} }` was printed as
`constructor(foo: string)`: the `TSParameterProperty` printer only emitted
`accessibility` and `readonly`, so the `override` flag was dropped. The
output no longer re-parses to the same AST and changes the program: tsc
rejects it under `noImplicitOverride`, and when `override` was the only
modifier the parameter stops being a parameter property, losing the
implicit `this.foo = foo` assignment. Print `override` between the
accessibility and `readonly`, matching `_tsPrintClassMemberModifiers`.

Assisted-by: Claude Fable 5.1 <[email protected]>
@JLHwung
JLHwung force-pushed the fix-generator-ts-parameter-property-override branch from f76314c to 0ebeadb Compare November 4, 2026 12:45
@babel-bot

Copy link
Copy Markdown
Collaborator

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

@nicolo-ribaudo
nicolo-ribaudo added this pull request to the merge queue Nov 4, 2026
Merged via the queue into babel:main with commit cc1f6e3 Nov 4, 2026
43 of 45 checks passed
@nicolo-ribaudo
nicolo-ribaudo deleted the fix-generator-ts-parameter-property-override branch November 4, 2026 14:55
@babel-bot

Copy link
Copy Markdown
Collaborator

Backported to 7.x in #18521.

JLHwung added a commit to JLHwung/babel that referenced this pull request Nov 10, 2026
…#18506)

`class C { constructor(override foo: string) {} }` was printed as
`constructor(foo: string)`: the `TSParameterProperty` printer only emitted
`accessibility` and `readonly`, so the `override` flag was dropped. The
output no longer re-parses to the same AST and changes the program: tsc
rejects it under `noImplicitOverride`, and when `override` was the only
modifier the parameter stops being a parameter property, losing the
implicit `this.foo = foo` assignment. Print `override` between the
accessibility and `readonly`, matching `_tsPrintClassMemberModifiers`.

Assisted-by: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: generator 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.

3 participants