Skip to content

[Babel 8] Add several TS type parentheses rules#17131

Merged
nicolo-ribaudo merged 6 commits intobabel:mainfrom
JLHwung:ts-parentheses-follow-up
Feb 14, 2025
Merged

[Babel 8] Add several TS type parentheses rules#17131
nicolo-ribaudo merged 6 commits intobabel:mainfrom
JLHwung:ts-parentheses-follow-up

Conversation

@JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Feb 12, 2025

Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

As a follow-up to #17125, this PR aims for adding parentheses rules for all TS productions from TSConditionalType descended all the way to non-array TS types. Here is a list in the order of their precedences:

TSConditionalType
TSFunctionType / TSConstrutorType
TSUnionType
TSIntersectionType
TSInferType / TSTypeOperator
TSArrayType / TSIndexedAccessType
TSOptionalType

Unlike TSOptionalType, it is safe to skip TSRestType because it is a prefix non-array-type operator, similar to typeof. Therefore I have removed the TSRestType check in the intersection/union rule as well as the test.

@JLHwung JLHwung added the PR: Bug Fix (next major) 🐛 A type of pull request used for our changelog categories for next major release label Feb 12, 2025
@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/58706

@JLHwung JLHwung changed the title Add several TS type parenthese rules [Babel 8] Add several TS type parentheses rules Feb 13, 2025
Copy link
Member

@liuxingbaoyu liuxingbaoyu left a comment

Choose a reason for hiding this comment

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

👍

@nicolo-ribaudo nicolo-ribaudo merged commit 6f27075 into babel:main Feb 14, 2025
55 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the ts-parentheses-follow-up branch February 14, 2025 11:13
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 17, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: typescript outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: generator PR: Bug Fix (next major) 🐛 A type of pull request used for our changelog categories for next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants