Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
105 additions
and
0 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,18 @@ | ||
#### Support `Labeled Tuple Elements` ([#8885](https://github.com/prettier/prettier/pull/8885) by [@fisker](https://github.com/fisker)) | ||
|
||
[`Labeled Tuple Elements`](https://devblogs.microsoft.com/typescript/announcing-typescript-4-0-beta/#labeled-tuple-elements) | ||
|
||
_Only works for `babel-ts` parser_ | ||
|
||
<!-- prettier-ignore --> | ||
```ts | ||
// Input | ||
type Range = [start: number, end: number]; | ||
|
||
// Prettier stable | ||
SyntaxError: Unexpected token, expected "," (1:20) | ||
> 1 | type Range = [start: number, end: number]; | ||
|
||
// Prettier master | ||
type Range = [start: number, end: number]; | ||
``` |
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
57 changes: 57 additions & 0 deletions
57
tests/misc/typescript-babel-only/__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,57 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`tuple-labeled.ts format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["babel-ts"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
// https://github.com/babel/babel/pull/11754 | ||
// TODO: move this file to \`test/typescript/tuple\` | ||
type T = [x: A, y?: B, ...z: C]; | ||
type T = [A, y: B]; | ||
let x: [A: string, ...B: number[]] | ||
type T = [foo: string, bar?: number]; | ||
type T = [x?: A, y: B]; | ||
type T = [x: A, ...B]; | ||
type T = [...B, x: A]; | ||
// Invalid label 1 | ||
type T = [x.y: A]; | ||
// Invalid label 2 | ||
type T = [x<y>: A]; | ||
=====================================output===================================== | ||
// https://github.com/babel/babel/pull/11754 | ||
// TODO: move this file to \`test/typescript/tuple\` | ||
type T = [x: A, y?: B, ...z: C]; | ||
type T = [A, y: B]; | ||
let x: [A: string, ...B: number[]]; | ||
type T = [foo: string, bar?: number]; | ||
type T = [x?: A, y: B]; | ||
type T = [x: A, ...B]; | ||
type T = [...B, x: A]; | ||
// Invalid label 1 | ||
type T = [x.y: A]; | ||
// Invalid label 2 | ||
type T = [x<y>: A]; | ||
================================================================================ | ||
`; |
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 @@ | ||
run_spec(__dirname, ["babel-ts"]); |
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,22 @@ | ||
// https://github.com/babel/babel/pull/11754 | ||
// TODO: move this file to `test/typescript/tuple` | ||
|
||
type T = [x: A, y?: B, ...z: C]; | ||
|
||
type T = [A, y: B]; | ||
|
||
let x: [A: string, ...B: number[]] | ||
|
||
type T = [foo: string, bar?: number]; | ||
|
||
type T = [x?: A, y: B]; | ||
|
||
type T = [x: A, ...B]; | ||
|
||
type T = [...B, x: A]; | ||
|
||
// Invalid label 1 | ||
type T = [x.y: A]; | ||
|
||
// Invalid label 2 | ||
type T = [x<y>: A]; |