fix(formatter): method signature missed a semicolon when it is on the same line with a property#17243
Conversation
CodSpeed Performance ReportMerging #17243 will not alter performanceComparing Summary
Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a formatter issue where method signatures were missing semicolons when appearing on the same line as a property in TypeScript type definitions. The fix refactors the semicolon insertion logic to be more maintainable while preserving the original behavior.
- Refactored the
Semicolons::AsNeededlogic from an early-return pattern to a more concisematches!expression - Added test cases demonstrating method signatures and properties on the same line
- Updated test snapshots to reflect the correct formatting behavior
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
crates/oxc_formatter/src/write/mod.rs |
Refactored semicolon insertion logic in FormatTSSignature::fmt to use matches! macro instead of early return pattern, improving code maintainability |
crates/oxc_formatter/tests/fixtures/ts/semi/method-signatures.ts |
Added test case with union type containing method signatures and properties on the same line |
crates/oxc_formatter/tests/fixtures/ts/semi/method-signatures.ts.snap |
Updated snapshot to include expected formatting output for the new test case across different configurations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Boshen
left a comment
There was a problem hiding this comment.
How come there were no existing test failures? An idempotent test should've caught this somewhere.
leaysgur
left a comment
There was a problem hiding this comment.
According to my quick research, this is the most relevant Prettier test case.
However, since the method signature in question is located at the end, it was not detected.
(In other words, it wasn't even tested in Prettier.)
|
Merge activity
|
54d12e5 to
6d03edd
Compare

close: #17151