Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ts] FIx parsing of nested
extends
type in arrow type (#14604)
- Loading branch information
1 parent
eab2b10
commit e8c4b78
Showing
7 changed files
with
238 additions
and
1 deletion.
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
1 change: 1 addition & 0 deletions
1
...el-parser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-param/input.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 @@ | ||
type Equals = A extends (x: B extends C ? D : E) => 0 ? F : G; |
3 changes: 3 additions & 0 deletions
3
...arser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-param/options.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,3 @@ | ||
{ | ||
"plugins": ["typescript"] | ||
} |
125 changes: 125 additions & 0 deletions
125
...parser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-param/output.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,125 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":62,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":62,"index":62}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":62,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":62,"index":62}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "TSTypeAliasDeclaration", | ||
"start":0,"end":62,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":62,"index":62}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":5,"end":11,"loc":{"start":{"line":1,"column":5,"index":5},"end":{"line":1,"column":11,"index":11},"identifierName":"Equals"}, | ||
"name": "Equals" | ||
}, | ||
"typeAnnotation": { | ||
"type": "TSConditionalType", | ||
"start":14,"end":61,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":61,"index":61}}, | ||
"checkType": { | ||
"type": "TSTypeReference", | ||
"start":14,"end":15,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":15,"index":15}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":14,"end":15,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":15,"index":15},"identifierName":"A"}, | ||
"name": "A" | ||
} | ||
}, | ||
"extendsType": { | ||
"type": "TSFunctionType", | ||
"start":24,"end":53,"loc":{"start":{"line":1,"column":24,"index":24},"end":{"line":1,"column":53,"index":53}}, | ||
"parameters": [ | ||
{ | ||
"type": "Identifier", | ||
"start":25,"end":47,"loc":{"start":{"line":1,"column":25,"index":25},"end":{"line":1,"column":47,"index":47},"identifierName":"x"}, | ||
"name": "x", | ||
"typeAnnotation": { | ||
"type": "TSTypeAnnotation", | ||
"start":26,"end":47,"loc":{"start":{"line":1,"column":26,"index":26},"end":{"line":1,"column":47,"index":47}}, | ||
"typeAnnotation": { | ||
"type": "TSConditionalType", | ||
"start":28,"end":47,"loc":{"start":{"line":1,"column":28,"index":28},"end":{"line":1,"column":47,"index":47}}, | ||
"checkType": { | ||
"type": "TSTypeReference", | ||
"start":28,"end":29,"loc":{"start":{"line":1,"column":28,"index":28},"end":{"line":1,"column":29,"index":29}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":28,"end":29,"loc":{"start":{"line":1,"column":28,"index":28},"end":{"line":1,"column":29,"index":29},"identifierName":"B"}, | ||
"name": "B" | ||
} | ||
}, | ||
"extendsType": { | ||
"type": "TSTypeReference", | ||
"start":38,"end":39,"loc":{"start":{"line":1,"column":38,"index":38},"end":{"line":1,"column":39,"index":39}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":38,"end":39,"loc":{"start":{"line":1,"column":38,"index":38},"end":{"line":1,"column":39,"index":39},"identifierName":"C"}, | ||
"name": "C" | ||
} | ||
}, | ||
"trueType": { | ||
"type": "TSTypeReference", | ||
"start":42,"end":43,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":43,"index":43}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":42,"end":43,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":43,"index":43},"identifierName":"D"}, | ||
"name": "D" | ||
} | ||
}, | ||
"falseType": { | ||
"type": "TSTypeReference", | ||
"start":46,"end":47,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":47,"index":47}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":46,"end":47,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":47,"index":47},"identifierName":"E"}, | ||
"name": "E" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"typeAnnotation": { | ||
"type": "TSTypeAnnotation", | ||
"start":49,"end":53,"loc":{"start":{"line":1,"column":49,"index":49},"end":{"line":1,"column":53,"index":53}}, | ||
"typeAnnotation": { | ||
"type": "TSLiteralType", | ||
"start":52,"end":53,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":53,"index":53}}, | ||
"literal": { | ||
"type": "NumericLiteral", | ||
"start":52,"end":53,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":53,"index":53}}, | ||
"extra": { | ||
"rawValue": 0, | ||
"raw": "0" | ||
}, | ||
"value": 0 | ||
} | ||
} | ||
} | ||
}, | ||
"trueType": { | ||
"type": "TSTypeReference", | ||
"start":56,"end":57,"loc":{"start":{"line":1,"column":56,"index":56},"end":{"line":1,"column":57,"index":57}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":56,"end":57,"loc":{"start":{"line":1,"column":56,"index":56},"end":{"line":1,"column":57,"index":57},"identifierName":"F"}, | ||
"name": "F" | ||
} | ||
}, | ||
"falseType": { | ||
"type": "TSTypeReference", | ||
"start":60,"end":61,"loc":{"start":{"line":1,"column":60,"index":60},"end":{"line":1,"column":61,"index":61}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":60,"end":61,"loc":{"start":{"line":1,"column":60,"index":60},"end":{"line":1,"column":61,"index":61},"identifierName":"G"}, | ||
"name": "G" | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...l-parser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-return/input.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 @@ | ||
type Equals = A extends () => B extends C ? D : E ? F : G; |
3 changes: 3 additions & 0 deletions
3
...rser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-return/options.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,3 @@ | ||
{ | ||
"plugins": ["typescript"] | ||
} |
102 changes: 102 additions & 0 deletions
102
...arser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-return/output.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,102 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":58,"index":58}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":58,"index":58}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "TSTypeAliasDeclaration", | ||
"start":0,"end":58,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":58,"index":58}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":5,"end":11,"loc":{"start":{"line":1,"column":5,"index":5},"end":{"line":1,"column":11,"index":11},"identifierName":"Equals"}, | ||
"name": "Equals" | ||
}, | ||
"typeAnnotation": { | ||
"type": "TSConditionalType", | ||
"start":14,"end":57,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":57,"index":57}}, | ||
"checkType": { | ||
"type": "TSTypeReference", | ||
"start":14,"end":15,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":15,"index":15}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":14,"end":15,"loc":{"start":{"line":1,"column":14,"index":14},"end":{"line":1,"column":15,"index":15},"identifierName":"A"}, | ||
"name": "A" | ||
} | ||
}, | ||
"extendsType": { | ||
"type": "TSFunctionType", | ||
"start":24,"end":49,"loc":{"start":{"line":1,"column":24,"index":24},"end":{"line":1,"column":49,"index":49}}, | ||
"parameters": [], | ||
"typeAnnotation": { | ||
"type": "TSTypeAnnotation", | ||
"start":27,"end":49,"loc":{"start":{"line":1,"column":27,"index":27},"end":{"line":1,"column":49,"index":49}}, | ||
"typeAnnotation": { | ||
"type": "TSConditionalType", | ||
"start":30,"end":49,"loc":{"start":{"line":1,"column":30,"index":30},"end":{"line":1,"column":49,"index":49}}, | ||
"checkType": { | ||
"type": "TSTypeReference", | ||
"start":30,"end":31,"loc":{"start":{"line":1,"column":30,"index":30},"end":{"line":1,"column":31,"index":31}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":30,"end":31,"loc":{"start":{"line":1,"column":30,"index":30},"end":{"line":1,"column":31,"index":31},"identifierName":"B"}, | ||
"name": "B" | ||
} | ||
}, | ||
"extendsType": { | ||
"type": "TSTypeReference", | ||
"start":40,"end":41,"loc":{"start":{"line":1,"column":40,"index":40},"end":{"line":1,"column":41,"index":41}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":40,"end":41,"loc":{"start":{"line":1,"column":40,"index":40},"end":{"line":1,"column":41,"index":41},"identifierName":"C"}, | ||
"name": "C" | ||
} | ||
}, | ||
"trueType": { | ||
"type": "TSTypeReference", | ||
"start":44,"end":45,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":45,"index":45}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":44,"end":45,"loc":{"start":{"line":1,"column":44,"index":44},"end":{"line":1,"column":45,"index":45},"identifierName":"D"}, | ||
"name": "D" | ||
} | ||
}, | ||
"falseType": { | ||
"type": "TSTypeReference", | ||
"start":48,"end":49,"loc":{"start":{"line":1,"column":48,"index":48},"end":{"line":1,"column":49,"index":49}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":48,"end":49,"loc":{"start":{"line":1,"column":48,"index":48},"end":{"line":1,"column":49,"index":49},"identifierName":"E"}, | ||
"name": "E" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"trueType": { | ||
"type": "TSTypeReference", | ||
"start":52,"end":53,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":53,"index":53}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":52,"end":53,"loc":{"start":{"line":1,"column":52,"index":52},"end":{"line":1,"column":53,"index":53},"identifierName":"F"}, | ||
"name": "F" | ||
} | ||
}, | ||
"falseType": { | ||
"type": "TSTypeReference", | ||
"start":56,"end":57,"loc":{"start":{"line":1,"column":56,"index":56},"end":{"line":1,"column":57,"index":57}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":56,"end":57,"loc":{"start":{"line":1,"column":56,"index":56},"end":{"line":1,"column":57,"index":57},"identifierName":"G"}, | ||
"name": "G" | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |