Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reinterpret << when parsing TS type arguments (#14145)
* refactor: split bitShift to bitShiftL and bitShiftR * fix: reinterpret bitShiftL to lt when parsing type arguments * test: update typescript allowlist * add Babel 8 test cases * test: simplify testcase * add more testcases
- Loading branch information
Showing
44 changed files
with
1,360 additions
and
15 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
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
...t/fixtures/typescript/type-arguments-bit-shift-left-like-babel-7/after-bit-shift/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 @@ | ||
f<<<T>(x) |
49 changes: 49 additions & 0 deletions
49
...ixtures/typescript/type-arguments-bit-shift-left-like-babel-7/after-bit-shift/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,49 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, | ||
"expression": { | ||
"type": "BinaryExpression", | ||
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, | ||
"left": { | ||
"type": "Identifier", | ||
"start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"f"}, | ||
"name": "f" | ||
}, | ||
"operator": "<<", | ||
"right": { | ||
"type": "TSTypeAssertion", | ||
"start":3,"end":9,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":9}}, | ||
"typeAnnotation": { | ||
"type": "TSTypeReference", | ||
"start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5},"identifierName":"T"}, | ||
"name": "T" | ||
} | ||
}, | ||
"expression": { | ||
"type": "Identifier", | ||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"}, | ||
"name": "x", | ||
"extra": { | ||
"parenthesized": true, | ||
"parenStart": 6 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...t/fixtures/typescript/type-arguments-bit-shift-left-like-babel-7/call-expression/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 @@ | ||
f<<T>(v: T) => void>(); |
76 changes: 76 additions & 0 deletions
76
...ixtures/typescript/type-arguments-bit-shift-left-like-babel-7/call-expression/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,76 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}}, | ||
"expression": { | ||
"type": "CallExpression", | ||
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, | ||
"callee": { | ||
"type": "Identifier", | ||
"start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"f"}, | ||
"name": "f" | ||
}, | ||
"arguments": [], | ||
"typeParameters": { | ||
"type": "TSTypeParameterInstantiation", | ||
"start":1,"end":20,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":20}}, | ||
"params": [ | ||
{ | ||
"type": "TSFunctionType", | ||
"start":2,"end":19,"loc":{"start":{"line":1,"column":2},"end":{"line":1,"column":19}}, | ||
"typeParameters": { | ||
"type": "TSTypeParameterDeclaration", | ||
"start":2,"end":5,"loc":{"start":{"line":1,"column":2},"end":{"line":1,"column":5}}, | ||
"params": [ | ||
{ | ||
"type": "TSTypeParameter", | ||
"start":3,"end":4,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":4}}, | ||
"name": "T" | ||
} | ||
] | ||
}, | ||
"parameters": [ | ||
{ | ||
"type": "Identifier", | ||
"start":6,"end":10,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":10},"identifierName":"v"}, | ||
"name": "v", | ||
"typeAnnotation": { | ||
"type": "TSTypeAnnotation", | ||
"start":7,"end":10,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":10}}, | ||
"typeAnnotation": { | ||
"type": "TSTypeReference", | ||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"T"}, | ||
"name": "T" | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"typeAnnotation": { | ||
"type": "TSTypeAnnotation", | ||
"start":12,"end":19,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":19}}, | ||
"typeAnnotation": { | ||
"type": "TSVoidKeyword", | ||
"start":15,"end":19,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":19}} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...st/fixtures/typescript/type-arguments-bit-shift-left-like-babel-7/class-heritage/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 @@ | ||
(class extends f<<T>(v: T) => void> {}); |
85 changes: 85 additions & 0 deletions
85
...fixtures/typescript/type-arguments-bit-shift-left-like-babel-7/class-heritage/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,85 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":40}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":40}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":40}}, | ||
"expression": { | ||
"type": "ClassExpression", | ||
"start":1,"end":38,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":38}}, | ||
"id": null, | ||
"superClass": { | ||
"type": "Identifier", | ||
"start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16},"identifierName":"f"}, | ||
"name": "f" | ||
}, | ||
"superTypeParameters": { | ||
"type": "TSTypeParameterInstantiation", | ||
"start":16,"end":35,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":35}}, | ||
"params": [ | ||
{ | ||
"type": "TSFunctionType", | ||
"start":17,"end":34,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":34}}, | ||
"typeParameters": { | ||
"type": "TSTypeParameterDeclaration", | ||
"start":17,"end":20,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":20}}, | ||
"params": [ | ||
{ | ||
"type": "TSTypeParameter", | ||
"start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}}, | ||
"name": "T" | ||
} | ||
] | ||
}, | ||
"parameters": [ | ||
{ | ||
"type": "Identifier", | ||
"start":21,"end":25,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":25},"identifierName":"v"}, | ||
"name": "v", | ||
"typeAnnotation": { | ||
"type": "TSTypeAnnotation", | ||
"start":22,"end":25,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":25}}, | ||
"typeAnnotation": { | ||
"type": "TSTypeReference", | ||
"start":24,"end":25,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":25}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":24,"end":25,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":25},"identifierName":"T"}, | ||
"name": "T" | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"typeAnnotation": { | ||
"type": "TSTypeAnnotation", | ||
"start":27,"end":34,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":34}}, | ||
"typeAnnotation": { | ||
"type": "TSVoidKeyword", | ||
"start":30,"end":34,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":34}} | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"body": { | ||
"type": "ClassBody", | ||
"start":36,"end":38,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":38}}, | ||
"body": [] | ||
}, | ||
"extra": { | ||
"parenthesized": true, | ||
"parenStart": 0 | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
.../typescript/type-arguments-bit-shift-left-like-babel-7/decorator-call-expression/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 @@ | ||
(@f<<T>(v: T) => void>() class {}); |
3 changes: 3 additions & 0 deletions
3
...escript/type-arguments-bit-shift-left-like-babel-7/decorator-call-expression/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": [["decorators", { "decoratorsBeforeExport": true }], "typescript"] | ||
} |
Oops, something went wrong.