-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/parser): Parse
yield<T> (v: T)=>v
(#9915)
**Related issue:** - Closes #9914
- Loading branch information
1 parent
5c8eaee
commit 04333aa
Showing
6 changed files
with
341 additions
and
24 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,6 @@ | ||
--- | ||
swc_core: patch | ||
swc_ecma_parser: patch | ||
--- | ||
|
||
fix(es/parser): Parse `yield<T> (v: T)=>v` |
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
3 changes: 3 additions & 0 deletions
3
crates/swc_ecma_parser/tests/typescript/issue-9914/1/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,3 @@ | ||
(function* () { | ||
yield <T>(v: T) => v; | ||
}); |
153 changes: 153 additions & 0 deletions
153
crates/swc_ecma_parser/tests/typescript/issue-9914/1/input.ts.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,153 @@ | ||
{ | ||
"type": "Script", | ||
"span": { | ||
"start": 1, | ||
"end": 46 | ||
}, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"span": { | ||
"start": 1, | ||
"end": 46 | ||
}, | ||
"expression": { | ||
"type": "ParenthesisExpression", | ||
"span": { | ||
"start": 1, | ||
"end": 45 | ||
}, | ||
"expression": { | ||
"type": "FunctionExpression", | ||
"identifier": null, | ||
"params": [], | ||
"decorators": [], | ||
"span": { | ||
"start": 2, | ||
"end": 44 | ||
}, | ||
"ctxt": 0, | ||
"body": { | ||
"type": "BlockStatement", | ||
"span": { | ||
"start": 15, | ||
"end": 44 | ||
}, | ||
"ctxt": 0, | ||
"stmts": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"span": { | ||
"start": 21, | ||
"end": 42 | ||
}, | ||
"expression": { | ||
"type": "YieldExpression", | ||
"span": { | ||
"start": 21, | ||
"end": 41 | ||
}, | ||
"argument": { | ||
"type": "ArrowFunctionExpression", | ||
"span": { | ||
"start": 27, | ||
"end": 41 | ||
}, | ||
"ctxt": 0, | ||
"params": [ | ||
{ | ||
"type": "Identifier", | ||
"span": { | ||
"start": 31, | ||
"end": 35 | ||
}, | ||
"ctxt": 0, | ||
"value": "v", | ||
"optional": false, | ||
"typeAnnotation": { | ||
"type": "TsTypeAnnotation", | ||
"span": { | ||
"start": 32, | ||
"end": 35 | ||
}, | ||
"typeAnnotation": { | ||
"type": "TsTypeReference", | ||
"span": { | ||
"start": 34, | ||
"end": 35 | ||
}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 34, | ||
"end": 35 | ||
}, | ||
"ctxt": 0, | ||
"value": "T", | ||
"optional": false | ||
}, | ||
"typeParams": null | ||
} | ||
} | ||
} | ||
], | ||
"body": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 40, | ||
"end": 41 | ||
}, | ||
"ctxt": 0, | ||
"value": "v", | ||
"optional": false | ||
}, | ||
"async": false, | ||
"generator": false, | ||
"typeParameters": { | ||
"type": "TsTypeParameterDeclaration", | ||
"span": { | ||
"start": 27, | ||
"end": 30 | ||
}, | ||
"parameters": [ | ||
{ | ||
"type": "TsTypeParameter", | ||
"span": { | ||
"start": 28, | ||
"end": 29 | ||
}, | ||
"name": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 28, | ||
"end": 29 | ||
}, | ||
"ctxt": 0, | ||
"value": "T", | ||
"optional": false | ||
}, | ||
"in": false, | ||
"out": false, | ||
"const": false, | ||
"constraint": null, | ||
"default": null | ||
} | ||
] | ||
}, | ||
"returnType": null | ||
}, | ||
"delegate": false | ||
} | ||
} | ||
] | ||
}, | ||
"generator": true, | ||
"async": false, | ||
"typeParameters": null, | ||
"returnType": null | ||
} | ||
} | ||
} | ||
], | ||
"interpreter": null | ||
} |
3 changes: 3 additions & 0 deletions
3
crates/swc_ecma_parser/tests/typescript/issue-9914/2/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,3 @@ | ||
(function* () { | ||
yield <T,>(v: T) => v; | ||
}); |
153 changes: 153 additions & 0 deletions
153
crates/swc_ecma_parser/tests/typescript/issue-9914/2/input.ts.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,153 @@ | ||
{ | ||
"type": "Script", | ||
"span": { | ||
"start": 1, | ||
"end": 47 | ||
}, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"span": { | ||
"start": 1, | ||
"end": 47 | ||
}, | ||
"expression": { | ||
"type": "ParenthesisExpression", | ||
"span": { | ||
"start": 1, | ||
"end": 46 | ||
}, | ||
"expression": { | ||
"type": "FunctionExpression", | ||
"identifier": null, | ||
"params": [], | ||
"decorators": [], | ||
"span": { | ||
"start": 2, | ||
"end": 45 | ||
}, | ||
"ctxt": 0, | ||
"body": { | ||
"type": "BlockStatement", | ||
"span": { | ||
"start": 15, | ||
"end": 45 | ||
}, | ||
"ctxt": 0, | ||
"stmts": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"span": { | ||
"start": 21, | ||
"end": 43 | ||
}, | ||
"expression": { | ||
"type": "YieldExpression", | ||
"span": { | ||
"start": 21, | ||
"end": 42 | ||
}, | ||
"argument": { | ||
"type": "ArrowFunctionExpression", | ||
"span": { | ||
"start": 27, | ||
"end": 42 | ||
}, | ||
"ctxt": 0, | ||
"params": [ | ||
{ | ||
"type": "Identifier", | ||
"span": { | ||
"start": 32, | ||
"end": 36 | ||
}, | ||
"ctxt": 0, | ||
"value": "v", | ||
"optional": false, | ||
"typeAnnotation": { | ||
"type": "TsTypeAnnotation", | ||
"span": { | ||
"start": 33, | ||
"end": 36 | ||
}, | ||
"typeAnnotation": { | ||
"type": "TsTypeReference", | ||
"span": { | ||
"start": 35, | ||
"end": 36 | ||
}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 35, | ||
"end": 36 | ||
}, | ||
"ctxt": 0, | ||
"value": "T", | ||
"optional": false | ||
}, | ||
"typeParams": null | ||
} | ||
} | ||
} | ||
], | ||
"body": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 41, | ||
"end": 42 | ||
}, | ||
"ctxt": 0, | ||
"value": "v", | ||
"optional": false | ||
}, | ||
"async": false, | ||
"generator": false, | ||
"typeParameters": { | ||
"type": "TsTypeParameterDeclaration", | ||
"span": { | ||
"start": 27, | ||
"end": 31 | ||
}, | ||
"parameters": [ | ||
{ | ||
"type": "TsTypeParameter", | ||
"span": { | ||
"start": 28, | ||
"end": 29 | ||
}, | ||
"name": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 28, | ||
"end": 29 | ||
}, | ||
"ctxt": 0, | ||
"value": "T", | ||
"optional": false | ||
}, | ||
"in": false, | ||
"out": false, | ||
"const": false, | ||
"constraint": null, | ||
"default": null | ||
} | ||
] | ||
}, | ||
"returnType": null | ||
}, | ||
"delegate": false | ||
} | ||
} | ||
] | ||
}, | ||
"generator": true, | ||
"async": false, | ||
"typeParameters": null, | ||
"returnType": null | ||
} | ||
} | ||
} | ||
], | ||
"interpreter": null | ||
} |