refactor(formatter): port is_complex_type_arguments from Prettier#19399
Merged
graphite-app[bot] merged 1 commit intomainfrom Feb 16, 2026
Merged
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
e7c46a1 to
46803f8
Compare
Member
Merge activity
|
…19399) I've found many differences caused by this in a private codebase. To fix this, we have to fully match this logic from Prettier, anyway. ## Summary - Replaces the heuristic approximation in `is_complex_type_arguments` with the actual Prettier approach: `willBreak(print(typeArgs))` via `f.intern(type_arguments).will_break()` - The previous code used custom `is_complex_type_reference` / `is_complex_ts_type` / `has_comment_in_span` heuristics to approximate the check - Comment cursor advancement from `f.intern()` is not a concern here because the caller already guards with `has_comment_in_span(call_expressions[0].span)` ## Test plan - [x] `cargo clippy -p oxc_formatter` — no warnings - [x] `cargo run -p oxc_prettier_conformance` — no regression (js 746/753, ts 591/601) - [x] `cargo run -p oxc_prettier_conformance -- --filter assignment` — all pass 🤖 Generated with [Claude Code](https://claude.com/claude-code)
46803f8 to
5f705e7
Compare
leaysgur
added a commit
that referenced
this pull request
Feb 16, 2026
graphite-app bot
pushed a commit
that referenced
this pull request
Feb 16, 2026
> https://github.com/oxc-project/monitor-oxc/actions/runs/22057084633/job/63727963672 Formatter DCR detected this: ```ts export const globalRegistry: $ZodRegistry<GlobalMeta> = /*@__PURE__*/ registry<GlobalMeta>(); ``` becomes ```ts export const globalRegistry: $ZodRegistry<GlobalMeta> = registry<GlobalMeta>(); ``` (`BlockComment` removed) So, I'll revert it for now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
is_complex_type_argumentswith the actual Prettier approach:willBreak(print(typeArgs))viaFormatter::will_break(type_arguments, span)Formatter::will_break(content, span)— a method that speculatively formats content and checks if it would break, with proper comment handling:span.start(so only comments within the content are processed)will_break()CommentStateSnapshotand snapshot/restore methods toCommentsComments::skip_comments_before(pos)to skip comments outside the span of interestThis ensures that speculative formatting only processes comments within the formatted content's span, preventing comment state corruption.
Test plan
cargo clippy -p oxc_formatter— no warningscargo run -p oxc_prettier_conformance— no regression (js 746/753, ts 591/601)🤖 Generated with Claude Code