forked from prettier/prettier
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flow: add support for 'implies' type guard variant (prettier#16272)
Co-authored-by: fisker Cheung <lionkay@gmail.com>
- Loading branch information
Showing
7 changed files
with
77 additions
and
9 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 @@ | ||
#### Support Flow's 'implies' type guard variant (#16272 by @gkz) | ||
|
||
Adds support for Flow's `implies` type guard variant. Also updates the `flow-parser` dependency. | ||
|
||
<!-- prettier-ignore --> | ||
```jsx | ||
// Input | ||
declare function f(x: mixed): implies x is T; | ||
|
||
// Prettier stable | ||
// error | ||
|
||
// Prettier main | ||
declare function f(x: mixed): implies x is 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
33 changes: 33 additions & 0 deletions
33
tests/format/flow/type-guards/__snapshots__/format.test.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,33 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`test.js [babel-flow] format 1`] = ` | ||
"Missing semicolon. (1:36) | ||
> 1 | declare function basic(x: mixed): x is string; | ||
| ^ | ||
2 | | ||
3 | declare function asserts(x: mixed): asserts x is string; | ||
4 | | ||
Cause: Missing semicolon. (1:35)" | ||
`; | ||
|
||
exports[`test.js format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["flow"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
declare function basic(x: mixed): x is string; | ||
declare function asserts(x: mixed): asserts x is string; | ||
declare function implies(x: mixed): implies x is string; | ||
=====================================output===================================== | ||
declare function basic(x: mixed): x is string; | ||
declare function asserts(x: mixed): asserts x is string; | ||
declare function implies(x: mixed): implies x is string; | ||
================================================================================ | ||
`; |
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,5 @@ | ||
runFormatTest(import.meta, ["flow"], { | ||
errors: { | ||
"babel-flow": ["test.js"], | ||
}, | ||
}); |
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,5 @@ | ||
declare function basic(x: mixed): x is string; | ||
|
||
declare function asserts(x: mixed): asserts x is string; | ||
|
||
declare function implies(x: mixed): implies x is string; |
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