fix(formatter): Complete is_complex_type_arguments() (take2)#17362
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
is_complex_type_arguments() (take2)
019e4b1 to
2b19b83
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #17275 by enhancing the is_complex_type_arguments function to correctly handle nested TSTypeReference types within type arguments. The fix ensures that generic types like Immutable<{...}> are properly recognized as complex, leading to correct line-breaking behavior in the formatter.
Key changes:
- Refactored
is_complex_type_argumentsto extract the complexity check into a closure for reusability - Added recursive checking for
TSTypeReferencetypes that contain type arguments - Added comprehensive test case demonstrating the fix for nested generic types
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
crates/oxc_formatter/src/utils/assignment_like.rs |
Enhanced is_complex_type_arguments to recursively check TSTypeReference types with type arguments, fixing the formatting issue for nested generics |
crates/oxc_formatter/tests/fixtures/ts/assignments/complex-type-arguments.ts |
Added test case for TSTypeReference with nested type literal to verify the fix |
crates/oxc_formatter/tests/fixtures/ts/assignments/complex-type-arguments.ts.snap |
Updated snapshot with expected formatting output for the new test case |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #17362 will not alter performanceComparing Summary
Footnotes
|
Merge activity
|
Fixes #17275, without `memoized.inspect(f)`.
2b19b83 to
c8c5341
Compare

Fixes #17275, without
memoized.inspect(f).