Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
fix parsing of leading union/intersection operator (#31265)
* fix parsing of leading union/intersection operator Fixes: #30995 * test declaration emit
- Loading branch information
Showing
8 changed files
with
102 additions
and
5 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
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
37 changes: 37 additions & 0 deletions
37
.../reference/JSDocParsing/TypeExpressions.parsesCorrectly.unionTypeWithLeadingOperator.json
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,37 @@ | ||
{ | ||
"kind": "ParenthesizedType", | ||
"pos": 1, | ||
"end": 22, | ||
"flags": "JSDoc", | ||
"modifierFlagsCache": 0, | ||
"transformFlags": 0, | ||
"type": { | ||
"kind": "UnionType", | ||
"pos": 2, | ||
"end": 20, | ||
"flags": "JSDoc", | ||
"modifierFlagsCache": 0, | ||
"transformFlags": 0, | ||
"types": { | ||
"0": { | ||
"kind": "NumberKeyword", | ||
"pos": 4, | ||
"end": 11, | ||
"flags": "JSDoc", | ||
"modifierFlagsCache": 0, | ||
"transformFlags": 0 | ||
}, | ||
"1": { | ||
"kind": "StringKeyword", | ||
"pos": 13, | ||
"end": 20, | ||
"flags": "JSDoc", | ||
"modifierFlagsCache": 0, | ||
"transformFlags": 0 | ||
}, | ||
"length": 2, | ||
"pos": 2, | ||
"end": 20 | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...DocParsing/TypeExpressions.parsesCorrectly.unionTypeWithOneElementAndLeadingOperator.json
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,29 @@ | ||
{ | ||
"kind": "ParenthesizedType", | ||
"pos": 1, | ||
"end": 13, | ||
"flags": "JSDoc", | ||
"modifierFlagsCache": 0, | ||
"transformFlags": 0, | ||
"type": { | ||
"kind": "UnionType", | ||
"pos": 2, | ||
"end": 11, | ||
"flags": "JSDoc", | ||
"modifierFlagsCache": 0, | ||
"transformFlags": 0, | ||
"types": { | ||
"0": { | ||
"kind": "NumberKeyword", | ||
"pos": 4, | ||
"end": 11, | ||
"flags": "JSDoc", | ||
"modifierFlagsCache": 0, | ||
"transformFlags": 0 | ||
}, | ||
"length": 1, | ||
"pos": 2, | ||
"end": 11 | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
// @declaration: true | ||
type A = | string; | ||
type B = | ||
| { type: "INCREMENT" } | ||
| { type: "DECREMENT" }; | ||
|
||
type C = [| 0 | 1, | "foo" | "bar"]; | ||
|
||
export type D = | ||
/*leading0*/ | ||
| /*leading1*/ 1 /*trailing1*/ | ||
| /*leading2*/ 2 /*trailing2*/; |