-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incorrect removal of parentheses when using an
infer
with a con…
…straint in a function predicate (#14279)
- Loading branch information
Showing
5 changed files
with
106 additions
and
23 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,16 @@ | ||
#### Fix parens in inferred function return types with `extends` (#14279 by @fisker) | ||
|
||
<!-- prettier-ignore --> | ||
```ts | ||
// Input | ||
type Foo<T> = T extends ((a) => a is infer R extends string) ? R : never; | ||
|
||
// Prettier stable (First format) | ||
type Foo<T> = T extends (a) => a is infer R extends string ? R : never; | ||
|
||
// Prettier stable (Second format) | ||
SyntaxError: '?' expected. | ||
|
||
// Prettier main | ||
type Foo<T> = T extends ((a) => a is infer R extends string) ? R : never; | ||
``` |
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 was deleted.
Oops, something went wrong.
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 @@ | ||
// #13275 | ||
type Foo<T> = T extends ((...a: any[]) => infer R extends string) ? R : never; | ||
type Foo<T> = T extends (new (...a: any[]) => infer R extends string) ? R : never; | ||
|
||
// #14275 | ||
type Test<T> = T extends (( | ||
token: TSESTree.Token | ||
) => token is infer U extends TSESTree.Token) | ||
? U | ||
: TSESTree.Token; | ||
type Test<T> = T extends (( | ||
token: TSESTree.Token | ||
) => asserts token is infer U extends TSESTree.Token) | ||
? U | ||
: TSESTree.Token; | ||
type Test<T> = T extends (new ( | ||
token: TSESTree.Token | ||
) => token is infer U extends TSESTree.Token) | ||
? U | ||
: TSESTree.Token; |