Skip to content

fix(formatter): Complete is_complex_type_arguments() (take2)#17362

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-26-fix_formatter_complete_is_complex_type_arguments_take2_
Dec 26, 2025
Merged

fix(formatter): Complete is_complex_type_arguments() (take2)#17362
graphite-app[bot] merged 1 commit intomainfrom
12-26-fix_formatter_complete_is_complex_type_arguments_take2_

Conversation

@leaysgur
Copy link
Member

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

@leaysgur leaysgur requested a review from Dunqing as a code owner December 26, 2025 01:20
Copilot AI review requested due to automatic review settings December 26, 2025 01:20
@github-actions github-actions bot added A-formatter Area - Formatter C-bug Category - Bug labels Dec 26, 2025
Copy link
Member Author

leaysgur commented Dec 26, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@leaysgur leaysgur changed the title fix(formatter): Complete is_complex_type_arguments(take2) fix(formatter): Complete is_complex_type_arguments() (take2) Dec 26, 2025
@leaysgur leaysgur force-pushed the 12-26-fix_formatter_complete_is_complex_type_arguments_take2_ branch from 019e4b1 to 2b19b83 Compare December 26, 2025 01:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_arguments to extract the complexity check into a closure for reusability
  • Added recursive checking for TSTypeReference types 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-hq
Copy link

codspeed-hq bot commented Dec 26, 2025

CodSpeed Performance Report

Merging #17362 will not alter performance

Comparing 12-26-fix_formatter_complete_is_complex_type_arguments_take2_ (2b19b83) with main (e8444bf)

Summary

✅ 38 untouched
⏩ 7 skipped1

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Member

@Dunqing Dunqing left a comment

Choose a reason for hiding this comment

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

Looks good now!

@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label Dec 26, 2025
Copy link
Member

Dunqing commented Dec 26, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the 12-26-fix_formatter_complete_is_complex_type_arguments_take2_ branch from 2b19b83 to c8c5341 Compare December 26, 2025 03:38
@graphite-app graphite-app bot merged commit c8c5341 into main Dec 26, 2025
20 checks passed
@graphite-app graphite-app bot deleted the 12-26-fix_formatter_complete_is_complex_type_arguments_take2_ branch December 26, 2025 03:44
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-formatter Area - Formatter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

formatter: Diff with Prettier on Generic Types

3 participants