Skip to content

Comments

refactor(formatter): improve printing of parentheses for TSTypeOperator#17792

Merged
graphite-app[bot] merged 1 commit intomainfrom
01-08-refactor_formatter_improve_printing_of_parentheses_for_tstypeoperator
Jan 9, 2026
Merged

refactor(formatter): improve printing of parentheses for TSTypeOperator#17792
graphite-app[bot] merged 1 commit intomainfrom
01-08-refactor_formatter_improve_printing_of_parentheses_for_tstypeoperator

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Jan 8, 2026

Parenthesis printing should be generated by AST tools.

@github-actions github-actions bot added A-ast-tools Area - AST tools A-formatter Area - Formatter labels Jan 8, 2026
Copy link
Member Author

Dunqing commented Jan 8, 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.

@github-actions github-actions bot added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Jan 8, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 8, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing 01-08-refactor_formatter_improve_printing_of_parentheses_for_tstypeoperator (3166319) with main (e2f534c)

Summary

✅ 38 untouched benchmarks
⏩ 7 skipped benchmarks1

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
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 refactors the printing of parentheses for TSTypeOperator to follow the established pattern used by similar TypeScript AST nodes in the formatter.

Key changes:

  • Added TSTypeOperator to the list of AST nodes that need parentheses generation
  • Moved parentheses printing logic from the write() method to the fmt() method
  • Added format_type_cast_comment_node handling for proper comment formatting

Reviewed changes

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

File Description
tasks/ast_tools/src/generators/formatter/format.rs Adds "TSTypeOperator" to AST_NODE_NEEDS_PARENTHESES constant
crates/oxc_formatter/src/write/mod.rs Removes parentheses logic from TSTypeOperator::write() method, simplifying it to only write the operator and type annotation
crates/oxc_formatter/src/ast_nodes/generated/format.rs Adds parentheses handling, type cast comment support, and proper formatting structure to TSTypeOperator::fmt() method

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

Copy link
Member

@leaysgur leaysgur left a comment

Choose a reason for hiding this comment

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

👀

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Jan 9, 2026
@graphite-app
Copy link
Contributor

graphite-app bot commented Jan 9, 2026

Merge activity

…or (#17792)

Parenthesis printing should be generated by AST tools.
@graphite-app graphite-app bot force-pushed the 01-08-refactor_formatter_improve_printing_of_parentheses_for_tstypeoperator branch from 3166319 to 89da592 Compare January 9, 2026 08:38
@graphite-app graphite-app bot merged commit 89da592 into main Jan 9, 2026
20 checks passed
@graphite-app graphite-app bot deleted the 01-08-refactor_formatter_improve_printing_of_parentheses_for_tstypeoperator branch January 9, 2026 08:44
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast-tools Area - AST tools A-formatter Area - Formatter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants