swc/crates/swc_ecma_parser/tests/tsc/forAwaitPerIterationBindingDownlevel.json

973 lines
38 KiB
JSON

{
"type": "Script",
"span": {
"start": 96,
"end": 692,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 96,
"end": 174,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 102,
"end": 173,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 102,
"end": 107,
"ctxt": 0
},
"value": "sleep",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ArrowFunctionExpression",
"span": {
"start": 110,
"end": 173,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 111,
"end": 121,
"ctxt": 0
},
"value": "tm",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 113,
"end": 121,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 115,
"end": 121,
"ctxt": 0
},
"kind": "number"
}
}
}
],
"body": {
"type": "NewExpression",
"span": {
"start": 126,
"end": 173,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 130,
"end": 137,
"ctxt": 0
},
"value": "Promise",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 138,
"end": 172,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 138,
"end": 145,
"ctxt": 0
},
"value": "resolve",
"optional": false,
"typeAnnotation": null
}
],
"body": {
"type": "CallExpression",
"span": {
"start": 149,
"end": 172,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 149,
"end": 159,
"ctxt": 0
},
"value": "setTimeout",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 160,
"end": 167,
"ctxt": 0
},
"value": "resolve",
"optional": false
}
},
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 169,
"end": 171,
"ctxt": 0
},
"value": "tm",
"optional": false
}
}
],
"typeArguments": null
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
}
],
"typeArguments": null
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
},
"definite": false
}
]
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 192,
"end": 195,
"ctxt": 0
},
"value": "gen",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 176,
"end": 250,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 198,
"end": 250,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 204,
"end": 212,
"ctxt": 0
},
"expression": {
"type": "YieldExpression",
"span": {
"start": 204,
"end": 211,
"ctxt": 0
},
"argument": {
"type": "NumericLiteral",
"span": {
"start": 210,
"end": 211,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"delegate": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 217,
"end": 235,
"ctxt": 0
},
"expression": {
"type": "AwaitExpression",
"span": {
"start": 217,
"end": 234,
"ctxt": 0
},
"argument": {
"type": "CallExpression",
"span": {
"start": 223,
"end": 234,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 223,
"end": 228,
"ctxt": 0
},
"value": "sleep",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 229,
"end": 233,
"ctxt": 0
},
"value": 1000.0,
"raw": "1000"
}
}
],
"typeArguments": null
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 240,
"end": 248,
"ctxt": 0
},
"expression": {
"type": "YieldExpression",
"span": {
"start": 240,
"end": 247,
"ctxt": 0
},
"argument": {
"type": "NumericLiteral",
"span": {
"start": 246,
"end": 247,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
},
"delegate": false
}
}
]
},
"generator": true,
"async": true,
"typeParameters": null,
"returnType": null
},
{
"type": "VariableDeclaration",
"span": {
"start": 252,
"end": 276,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 258,
"end": 275,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 258,
"end": 261,
"ctxt": 0
},
"value": "log",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "MemberExpression",
"span": {
"start": 264,
"end": 275,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 264,
"end": 271,
"ctxt": 0
},
"value": "console",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 272,
"end": 275,
"ctxt": 0
},
"value": "log",
"optional": false
}
},
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 278,
"end": 692,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 278,
"end": 691,
"ctxt": 0
},
"callee": {
"type": "ParenthesisExpression",
"span": {
"start": 278,
"end": 689,
"ctxt": 0
},
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 279,
"end": 688,
"ctxt": 0
},
"params": [],
"body": {
"type": "BlockStatement",
"span": {
"start": 291,
"end": 688,
"ctxt": 0
},
"stmts": [
{
"type": "ForOfStatement",
"span": {
"start": 297,
"end": 686,
"ctxt": 0
},
"await": {
"start": 301,
"end": 306,
"ctxt": 0
},
"left": {
"type": "VariableDeclaration",
"span": {
"start": 308,
"end": 319,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 314,
"end": 319,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 314,
"end": 319,
"ctxt": 0
},
"value": "outer",
"optional": false,
"typeAnnotation": null
},
"init": null,
"definite": false
}
]
},
"right": {
"type": "CallExpression",
"span": {
"start": 323,
"end": 328,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 323,
"end": 326,
"ctxt": 0
},
"value": "gen",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"body": {
"type": "BlockStatement",
"span": {
"start": 330,
"end": 686,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 340,
"end": 365,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 340,
"end": 364,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 340,
"end": 343,
"ctxt": 0
},
"value": "log",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "TemplateLiteral",
"span": {
"start": 344,
"end": 363,
"ctxt": 0
},
"expressions": [
{
"type": "Identifier",
"span": {
"start": 356,
"end": 361,
"ctxt": 0
},
"value": "outer",
"optional": false
}
],
"quasis": [
{
"type": "TemplateElement",
"span": {
"start": 345,
"end": 354,
"ctxt": 0
},
"tail": false,
"cooked": "I'm loop ",
"raw": "I'm loop "
},
{
"type": "TemplateElement",
"span": {
"start": 362,
"end": 362,
"ctxt": 0
},
"tail": true,
"cooked": "",
"raw": ""
}
]
}
}
],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 374,
"end": 680,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 374,
"end": 679,
"ctxt": 0
},
"callee": {
"type": "ParenthesisExpression",
"span": {
"start": 374,
"end": 677,
"ctxt": 0
},
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 375,
"end": 676,
"ctxt": 0
},
"params": [],
"body": {
"type": "BlockStatement",
"span": {
"start": 387,
"end": 676,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 401,
"end": 421,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 407,
"end": 420,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 407,
"end": 412,
"ctxt": 0
},
"value": "inner",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "Identifier",
"span": {
"start": 415,
"end": 420,
"ctxt": 0
},
"value": "outer",
"optional": false
},
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 434,
"end": 452,
"ctxt": 0
},
"expression": {
"type": "AwaitExpression",
"span": {
"start": 434,
"end": 451,
"ctxt": 0
},
"argument": {
"type": "CallExpression",
"span": {
"start": 440,
"end": 451,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 440,
"end": 445,
"ctxt": 0
},
"value": "sleep",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 446,
"end": 450,
"ctxt": 0
},
"value": 2000.0,
"raw": "2000"
}
}
],
"typeArguments": null
}
}
},
{
"type": "IfStatement",
"span": {
"start": 465,
"end": 666,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 469,
"end": 484,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "Identifier",
"span": {
"start": 469,
"end": 474,
"ctxt": 0
},
"value": "inner",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 479,
"end": 484,
"ctxt": 0
},
"value": "outer",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 486,
"end": 572,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 504,
"end": 558,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 504,
"end": 557,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 504,
"end": 507,
"ctxt": 0
},
"value": "log",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "TemplateLiteral",
"span": {
"start": 508,
"end": 556,
"ctxt": 0
},
"expressions": [
{
"type": "Identifier",
"span": {
"start": 520,
"end": 525,
"ctxt": 0
},
"value": "inner",
"optional": false
},
{
"type": "Identifier",
"span": {
"start": 549,
"end": 554,
"ctxt": 0
},
"value": "outer",
"optional": false
}
],
"quasis": [
{
"type": "TemplateElement",
"span": {
"start": 509,
"end": 518,
"ctxt": 0
},
"tail": false,
"cooked": "I'm loop ",
"raw": "I'm loop "
},
{
"type": "TemplateElement",
"span": {
"start": 526,
"end": 547,
"ctxt": 0
},
"tail": false,
"cooked": " and I know I'm loop ",
"raw": " and I know I'm loop "
},
{
"type": "TemplateElement",
"span": {
"start": 555,
"end": 555,
"ctxt": 0
},
"tail": true,
"cooked": "",
"raw": ""
}
]
}
}
],
"typeArguments": null
}
}
]
},
"alternate": {
"type": "BlockStatement",
"span": {
"start": 578,
"end": 666,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 596,
"end": 652,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 596,
"end": 651,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 596,
"end": 599,
"ctxt": 0
},
"value": "log",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "TemplateLiteral",
"span": {
"start": 600,
"end": 650,
"ctxt": 0
},
"expressions": [
{
"type": "Identifier",
"span": {
"start": 612,
"end": 617,
"ctxt": 0
},
"value": "inner",
"optional": false
},
{
"type": "Identifier",
"span": {
"start": 643,
"end": 648,
"ctxt": 0
},
"value": "outer",
"optional": false
}
],
"quasis": [
{
"type": "TemplateElement",
"span": {
"start": 601,
"end": 610,
"ctxt": 0
},
"tail": false,
"cooked": "I'm loop ",
"raw": "I'm loop "
},
{
"type": "TemplateElement",
"span": {
"start": 618,
"end": 641,
"ctxt": 0
},
"tail": false,
"cooked": ", but I think I'm loop ",
"raw": ", but I think I'm loop "
},
{
"type": "TemplateElement",
"span": {
"start": 649,
"end": 649,
"ctxt": 0
},
"tail": true,
"cooked": "",
"raw": ""
}
]
}
}
],
"typeArguments": null
}
}
]
}
}
]
},
"async": true,
"generator": false,
"typeParameters": null,
"returnType": null
}
},
"arguments": [],
"typeArguments": null
}
}
]
}
}
]
},
"async": true,
"generator": false,
"typeParameters": null,
"returnType": null
}
},
"arguments": [],
"typeArguments": null
}
}
],
"interpreter": null
}