Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(js_formatter): disambiguate parametrized arrow functions and JSX elements #872

Merged

Conversation

Conaclos
Copy link
Member

Summary

Fix #832 and the following divergences:

Useless trailing commas are now removed in type parameter lists.
We keep the trailing comma in the case where:

  • the type parameter list is attached to an arrow function.
  • the type parameter list contains a single type parameter without any constraint (i.e. without extends clause).
  • The source allows JSX or has the extension cts or mts.

The last condition requires introducing a new language variant, I named StandardRestricted.
This variant doesn't allow JSX, but adds extra restriction to be future-proof (if one day TSC decides to allow JSX for these extensions).
See the related Prettier changelog line and TypeScript design notes.

Test Plan

  • Updated snapshots
  • New tests

@Conaclos Conaclos temporarily deployed to Website deployment November 24, 2023 22:25 — with GitHub Actions Inactive
@Conaclos Conaclos requested a review from ematipico November 24, 2023 22:25
@github-actions github-actions bot added A-Parser Area: parser A-Formatter Area: formatter A-Tooling Area: internal tools A-Website Area: website L-JavaScript Language: JavaScript and super languages A-Changelog Area: changelog labels Nov 24, 2023
Copy link
Contributor

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 49701 49701 0
Passed 48721 48721 0
Failed 980 980 0
Panics 0 0 0
Coverage 98.03% 98.03% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 40 40 0
Passed 37 37 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.50% 92.50% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 6322 6322 0
Passed 2036 2036 0
Failed 4286 4286 0
Panics 0 0 0
Coverage 32.20% 32.20% 0.00%

ts/babel

Test result main count This PR count Difference
Total 662 662 0
Passed 592 592 0
Failed 70 70 0
Panics 0 0 0
Coverage 89.43% 89.43% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 17646 17646 0
Passed 13453 13453 0
Failed 4191 4191 0
Panics 2 2 0
Coverage 76.24% 76.24% 0.00%

@Conaclos Conaclos changed the title fix(js_formatter): desambigaute parametrized arrow functions and JSX alements fix(js_formatter): disambiguate parametrized arrow functions and JSX elements Nov 24, 2023
@Conaclos Conaclos merged commit 4f1a500 into main Nov 24, 2023
18 checks passed
@Conaclos Conaclos deleted the conaclos/js_formatter/type-parameter-list-trailing-comma branch November 24, 2023 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-Formatter Area: formatter A-Parser Area: parser A-Tooling Area: internal tools A-Website Area: website L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 unnecessary trailing comma in type parameter list
2 participants