forked from prettier/prettier
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix trailing coma print in type prameters, improve jsx parse (prettie…
…r#14688) Co-authored-by: fisker Cheung <lionkay@gmail.com>
- Loading branch information
1 parent
b5043bc
commit cfb3b87
Showing
18 changed files
with
214 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#### Fix missing required comma in type parameters (#14688 by @fisker, @sosukesuzuki) | ||
|
||
Previously, we only print trailing comma when file extension is `.tsx`, turns out `.mts`, `.cts` files requires it to parse too. | ||
|
||
<!-- prettier-ignore --> | ||
```tsx | ||
// Input | ||
export const unsafeCoerce = <T,>(u: unknown): T => u as T | ||
|
||
// Prettier stable | ||
export const unsafeCoerce = <T>(u: unknown): T => u as T; | ||
|
||
// Prettier main | ||
export const unsafeCoerce = <T,>(u: unknown): T => u as T; | ||
``` |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
File renamed without changes.
This file contains 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
File renamed without changes.
File renamed without changes.
This file contains 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
File renamed without changes.
File renamed without changes.
131 changes: 131 additions & 0 deletions
131
tests/format/typescript/tsx/comma/__snapshots__/jsfmt.spec.js.snap
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`snippet: test.cjs format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["typescript"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
const A = <T,>() => {} | ||
=====================================output===================================== | ||
const A = <T,>() => {}; | ||
================================================================================ | ||
`; | ||
|
||
exports[`snippet: test.cts format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["typescript"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
const A = <T,>() => {} | ||
=====================================output===================================== | ||
const A = <T,>() => {}; | ||
================================================================================ | ||
`; | ||
|
||
exports[`snippet: test.js format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["typescript"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
const A = <T,>() => {} | ||
=====================================output===================================== | ||
const A = <T,>() => {}; | ||
================================================================================ | ||
`; | ||
|
||
exports[`snippet: test.jsx format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["typescript"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
const A = <T,>() => {} | ||
=====================================output===================================== | ||
const A = <T,>() => {}; | ||
================================================================================ | ||
`; | ||
|
||
exports[`snippet: test.mjs format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["typescript"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
const A = <T,>() => {} | ||
=====================================output===================================== | ||
const A = <T,>() => {}; | ||
================================================================================ | ||
`; | ||
|
||
exports[`snippet: test.mts format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["typescript"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
const A = <T,>() => {} | ||
=====================================output===================================== | ||
const A = <T,>() => {}; | ||
================================================================================ | ||
`; | ||
|
||
exports[`snippet: test.ts format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["typescript"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
const A = <T,>() => {} | ||
=====================================output===================================== | ||
const A = <T>() => {}; | ||
================================================================================ | ||
`; | ||
exports[`snippet: test.tsx format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["typescript"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
const A = <T,>() => {} | ||
=====================================output===================================== | ||
const A = <T,>() => {}; | ||
================================================================================ | ||
`; | ||
exports[`snippet: test.unknown format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["typescript"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
const A = <T,>() => {} | ||
=====================================output===================================== | ||
const A = <T,>() => {}; | ||
================================================================================ | ||
`; | ||
exports[`snippet: unnamed format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["typescript"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
const A = <T,>() => {} | ||
=====================================output===================================== | ||
const A = <T,>() => {}; | ||
================================================================================ | ||
`; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const code = "const A = <T,>() => {}"; | ||
|
||
run_spec( | ||
{ | ||
importMeta: import.meta, | ||
snippets: [ | ||
"test.js", | ||
"test.cjs", | ||
"test.mjs", | ||
"test.ts", | ||
"test.jsx", | ||
"test.mts", | ||
"test.cts", | ||
"test.tsx", | ||
"test.unknown", | ||
undefined, | ||
].map((filename) => ({ code, filename, name: filename ?? "unnamed" })), | ||
}, | ||
["typescript"] | ||
); |
2 changes: 1 addition & 1 deletion
2
tests/format/typescript/typeparams/print-width-120/__snapshots__/jsfmt.spec.js.snap
This file contains 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
File renamed without changes.
This file contains 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