Skip to content

fix(formatter): should not treat multi-type arguments of TSTypeReference as a complex type#17708

Merged
graphite-app[bot] merged 1 commit intomainfrom
01-06-fix_formatter_should_not_treat_multi-type_arguments_of_tstypereference_as_a_complex_type
Jan 6, 2026
Merged

fix(formatter): should not treat multi-type arguments of TSTypeReference as a complex type#17708
graphite-app[bot] merged 1 commit intomainfrom
01-06-fix_formatter_should_not_treat_multi-type_arguments_of_tstypereference_as_a_complex_type

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Jan 6, 2026

Input:

// Non-complex type arguments, as none of the type arguments of Record is a complex type.
const result = configurationService.getValue<Record<string, boolean>>(
  enalementSetting
);

Before output:

// Non-complex type arguments, as none of the type arguments of Record is a complex type.
const result = configurationService.getValue<
  Record<string, boolean>
>(enalementSetting);

Prettier Playground
After output:

// Non-complex type arguments, as none of the type arguments of Record is a complex type.
const result =
  configurationService.getValue<Record<string, boolean>>(enalementSetting);

@github-actions github-actions bot added A-formatter Area - Formatter C-bug Category - Bug labels Jan 6, 2026
Copy link
Member Author

Dunqing commented Jan 6, 2026


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.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 6, 2026

CodSpeed Performance Report

Merging #17708 will not alter performance

Comparing 01-06-fix_formatter_should_not_treat_multi-type_arguments_of_tstypereference_as_a_complex_type (90c6356) with main (c6a99fd)

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.

@Dunqing Dunqing marked this pull request as ready for review January 6, 2026 09:11
@Dunqing Dunqing requested review from Copilot and leaysgur January 6, 2026 09:11
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 a formatter bug where type arguments in TSTypeReference were incorrectly considered complex when they contained multiple type parameters, even if none of those parameters were actually complex types. The fix ensures that Record<string, boolean> is not treated as a complex type, preventing unnecessary line breaks in formatted code.

Key changes:

  • Modified the logic in is_complex_type_arguments to check individual type parameters instead of recursively calling itself
  • Added a test case demonstrating the fix with Record<string, boolean>

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
crates/oxc_formatter/src/utils/assignment_like.rs Changed the logic from recursively checking if nested type arguments are complex (which would return true for >1 params) to checking if any individual nested type parameter is a complex type
crates/oxc_formatter/tests/fixtures/ts/assignments/complex-type-arguments.ts Added test case with Record<string, boolean> to verify non-complex multi-parameter types are handled correctly
crates/oxc_formatter/tests/fixtures/ts/assignments/complex-type-arguments.ts.snap Updated snapshot with expected output for the new test case at different print widths

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@leaysgur leaysgur added the 0-merge Merge with Graphite Merge Queue label Jan 6, 2026
Copy link
Member

leaysgur commented Jan 6, 2026

Merge activity

…nce as a complex type (#17708)

**Input:**
<!-- prettier-ignore -->
```tsx

// Non-complex type arguments, as none of the type arguments of Record is a complex type.
const result = configurationService.getValue<Record<string, boolean>>(
  enalementSetting
);
```

**Before output:**
<!-- prettier-ignore -->
```tsx
// Non-complex type arguments, as none of the type arguments of Record is a complex type.
const result = configurationService.getValue<
  Record<string, boolean>
>(enalementSetting);

```

[Prettier Playground](https://prettier.io/playground/#N4Igxg9gdgLgprEAuEAdKB6DACActAWkgFsAHAGzgA9sYBPUubAQwCcBzAV2IRgGcANCz7Yo0JhABmtABZN6jFh268RU7ACU4kVgBNsASxHNsJCtVoM4AOnSQofGNlZw+nck4C8p6JINdWZhgDaABlOFYANwMwG3Y4GAA1ZnJOOAAeLR1ddMdWAyh2IQAjCAhKZigAPiqACnRsbAQUuB5YcJhgwvQASgBuEAEQCFJg6D5kUDZWCAB3AAU2BAmUFNnmOgmh4sCwAGsE0OYeABkCuGRJFL44IYhigCttGAB1QNJkEFIXG6iL7d2BxgoVIzDABXYyBgrDSQxuxAMUJhtxA1EY+TaMBSAHl0UEIKx5hA+AYxlBPghdINUVR0QZMSkACoRKBsAyuS7XFEkwqUACKnAg8E55BuQwefCooQh-MFwqQV1FKIAjnK4PMZqQViBmHwCFA4HBdEbqdDmAZyBCAMIQYjEZifFLkak89iUACCnXyxU48HmETOBpFYpAMhgxHILxkpNcoNi4QcpIM0XonzAfC2IEiaQAklBje0wPlRu786F6JRgyjvsS4G9mB8UN9XBFIv9UfnsZJAxcUORJNSCr8YBrmOx7VWhqDWL9PsVmMU4OQCPxqd8Cq8DLoYDJkAAOAAMQxcqoMLlH44dCq5QyxxReW53yAATENODdGQuVoqQ61F7pjV0E5Ki4Mc4AAMQJe1OghR1fQgEAAF9EKAA)
**After output:**
<!-- prettier-ignore -->
```tsx
// Non-complex type arguments, as none of the type arguments of Record is a complex type.
const result =
  configurationService.getValue<Record<string, boolean>>(enalementSetting);

```
@graphite-app graphite-app bot force-pushed the 01-06-fix_formatter_should_not_treat_multi-type_arguments_of_tstypereference_as_a_complex_type branch from 90c6356 to 3b4aced Compare January 6, 2026 09:36
@graphite-app graphite-app bot merged commit 3b4aced into main Jan 6, 2026
20 checks passed
@graphite-app graphite-app bot deleted the 01-06-fix_formatter_should_not_treat_multi-type_arguments_of_tstypereference_as_a_complex_type branch January 6, 2026 09:43
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 6, 2026
Dunqing added a commit that referenced this pull request Jan 6, 2026
# Oxlint

# Oxfmt
### 🚀 Features

- a19cc93 oxfmt: Add debug logging to oxfmt LSP to troubleshoot resolved
options at runtime (#17695) (Nicholas Rayburn)

### 🐛 Bug Fixes

- 3b4aced formatter: Should not treat multi-type arguments of
TSTypeReference as a complex type (#17708) (Dunqing)
- dcfdd41 formatter: Should not set up tailwindcss callback when no
tailwindcss configuration is set (#17696) (Dunqing)
- 6f65901 formatter: Return original classes when there are no
tailwindcss classes sort callback (#17689) (Dunqing)

### ⚡ Performance

- c6a99fd formatter: Don't call `sort_tailwind_classes` if no classes
need to be sorted (#17698) (Dunqing)

Co-authored-by: Dunqing <29533304+Dunqing@users.noreply.github.com>
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.

3 participants