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

1490 lines
38 KiB
JSON

{
"type": "Script",
"span": {
"start": 166,
"end": 1358,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 166,
"end": 189,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 170,
"end": 189,
"ctxt": 0
},
"id": {
"type": "ArrayPattern",
"span": {
"start": 170,
"end": 184,
"ctxt": 0
},
"elements": [
{
"type": "ArrayPattern",
"span": {
"start": 171,
"end": 175,
"ctxt": 0
},
"elements": [
{
"type": "Identifier",
"span": {
"start": 172,
"end": 174,
"ctxt": 0
},
"value": "a0",
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
},
{
"type": "ArrayPattern",
"span": {
"start": 177,
"end": 183,
"ctxt": 0
},
"elements": [
{
"type": "ArrayPattern",
"span": {
"start": 178,
"end": 182,
"ctxt": 0
},
"elements": [
{
"type": "Identifier",
"span": {
"start": 179,
"end": 181,
"ctxt": 0
},
"value": "a1",
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ArrayExpression",
"span": {
"start": 187,
"end": 189,
"ctxt": 0
},
"elements": []
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 207,
"end": 237,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 211,
"end": 237,
"ctxt": 0
},
"id": {
"type": "ArrayPattern",
"span": {
"start": 211,
"end": 225,
"ctxt": 0
},
"elements": [
{
"type": "ArrayPattern",
"span": {
"start": 212,
"end": 216,
"ctxt": 0
},
"elements": [
{
"type": "Identifier",
"span": {
"start": 213,
"end": 215,
"ctxt": 0
},
"value": "a2",
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
},
{
"type": "ArrayPattern",
"span": {
"start": 218,
"end": 224,
"ctxt": 0
},
"elements": [
{
"type": "ArrayPattern",
"span": {
"start": 219,
"end": 223,
"ctxt": 0
},
"elements": [
{
"type": "Identifier",
"span": {
"start": 220,
"end": 222,
"ctxt": 0
},
"value": "a3",
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "Identifier",
"span": {
"start": 228,
"end": 237,
"ctxt": 0
},
"value": "undefined",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 591,
"end": 654,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 595,
"end": 653,
"ctxt": 0
},
"id": {
"type": "ArrayPattern",
"span": {
"start": 595,
"end": 607,
"ctxt": 0
},
"elements": [
{
"type": "Identifier",
"span": {
"start": 596,
"end": 598,
"ctxt": 0
},
"value": "b0",
"optional": false,
"typeAnnotation": null
},
{
"type": "Identifier",
"span": {
"start": 600,
"end": 602,
"ctxt": 0
},
"value": "b1",
"optional": false,
"typeAnnotation": null
},
{
"type": "Identifier",
"span": {
"start": 604,
"end": 606,
"ctxt": 0
},
"value": "b2",
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 607,
"end": 634,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTupleType",
"span": {
"start": 609,
"end": 634,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 610,
"end": 616,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 610,
"end": 616,
"ctxt": 0
},
"kind": "number"
}
},
{
"type": "TsTupleElement",
"span": {
"start": 618,
"end": 625,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 618,
"end": 625,
"ctxt": 0
},
"kind": "boolean"
}
},
{
"type": "TsTupleElement",
"span": {
"start": 627,
"end": 633,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 627,
"end": 633,
"ctxt": 0
},
"kind": "string"
}
}
]
}
}
},
"init": {
"type": "ArrayExpression",
"span": {
"start": 637,
"end": 653,
"ctxt": 0
},
"elements": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 638,
"end": 639,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
},
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 641,
"end": 642,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
}
},
{
"spread": null,
"expression": {
"type": "StringLiteral",
"span": {
"start": 644,
"end": 652,
"ctxt": 0
},
"value": "string",
"raw": "\"string\""
}
}
]
},
"definite": false
}
]
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 665,
"end": 717,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 675,
"end": 676,
"ctxt": 0
},
"value": "J",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 685,
"end": 698,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 685,
"end": 690,
"ctxt": 0
},
"value": "Array",
"optional": false
},
"typeArguments": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 690,
"end": 698,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 691,
"end": 697,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 691,
"end": 697,
"ctxt": 0
},
"value": "Number",
"optional": false
},
"typeParams": null
}
]
}
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 699,
"end": 717,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 705,
"end": 715,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
"start": 705,
"end": 706,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 706,
"end": 714,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 708,
"end": 714,
"ctxt": 0
},
"kind": "number"
}
},
"typeParams": null
}
]
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 728,
"end": 731,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 719,
"end": 788,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 737,
"end": 788,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 743,
"end": 786,
"ctxt": 0
},
"argument": {
"type": "TsTypeAssertion",
"span": {
"start": 750,
"end": 785,
"ctxt": 0
},
"expression": {
"type": "ArrayExpression",
"span": {
"start": 776,
"end": 785,
"ctxt": 0
},
"elements": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 777,
"end": 778,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
},
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 780,
"end": 781,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
}
},
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 783,
"end": 784,
"ctxt": 0
},
"value": 3.0,
"raw": "3"
}
}
]
},
"typeAnnotation": {
"type": "TsTupleType",
"span": {
"start": 751,
"end": 775,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 752,
"end": 758,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 752,
"end": 758,
"ctxt": 0
},
"kind": "number"
}
},
{
"type": "TsTupleElement",
"span": {
"start": 760,
"end": 766,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 760,
"end": 766,
"ctxt": 0
},
"kind": "number"
}
},
{
"type": "TsTupleElement",
"span": {
"start": 768,
"end": 774,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 768,
"end": 774,
"ctxt": 0
},
"kind": "number"
}
}
]
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 733,
"end": 736,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 735,
"end": 736,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 735,
"end": 736,
"ctxt": 0
},
"value": "J",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 789,
"end": 825,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 793,
"end": 824,
"ctxt": 0
},
"id": {
"type": "ArrayPattern",
"span": {
"start": 793,
"end": 816,
"ctxt": 0
},
"elements": [
{
"type": "AssignmentPattern",
"span": {
"start": 794,
"end": 807,
"ctxt": 0
},
"left": {
"type": "Identifier",
"span": {
"start": 794,
"end": 796,
"ctxt": 0
},
"value": "b3",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 799,
"end": 807,
"ctxt": 0
},
"value": "string",
"raw": "\"string\""
},
"typeAnnotation": null
},
{
"type": "Identifier",
"span": {
"start": 809,
"end": 811,
"ctxt": 0
},
"value": "b4",
"optional": false,
"typeAnnotation": null
},
{
"type": "Identifier",
"span": {
"start": 813,
"end": 815,
"ctxt": 0
},
"value": "b5",
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 819,
"end": 824,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 819,
"end": 822,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 1090,
"end": 1110,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 1094,
"end": 1110,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 1094,
"end": 1098,
"ctxt": 0
},
"value": "temp",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ArrayExpression",
"span": {
"start": 1101,
"end": 1110,
"ctxt": 0
},
"elements": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 1102,
"end": 1103,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
},
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 1105,
"end": 1106,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
}
},
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 1108,
"end": 1109,
"ctxt": 0
},
"value": 3.0,
"raw": "3"
}
}
]
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 1111,
"end": 1154,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 1115,
"end": 1153,
"ctxt": 0
},
"id": {
"type": "ArrayPattern",
"span": {
"start": 1115,
"end": 1123,
"ctxt": 0
},
"elements": [
{
"type": "Identifier",
"span": {
"start": 1116,
"end": 1118,
"ctxt": 0
},
"value": "c0",
"optional": false,
"typeAnnotation": null
},
{
"type": "Identifier",
"span": {
"start": 1120,
"end": 1122,
"ctxt": 0
},
"value": "c1",
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1123,
"end": 1141,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTupleType",
"span": {
"start": 1125,
"end": 1141,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 1126,
"end": 1132,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 1126,
"end": 1132,
"ctxt": 0
},
"kind": "number"
}
},
{
"type": "TsTupleElement",
"span": {
"start": 1134,
"end": 1140,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 1134,
"end": 1140,
"ctxt": 0
},
"kind": "number"
}
}
]
}
}
},
"init": {
"type": "ArrayExpression",
"span": {
"start": 1144,
"end": 1153,
"ctxt": 0
},
"elements": [
{
"spread": {
"start": 1145,
"end": 1148,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 1148,
"end": 1152,
"ctxt": 0
},
"value": "temp",
"optional": false
}
}
]
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 1165,
"end": 1208,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 1169,
"end": 1207,
"ctxt": 0
},
"id": {
"type": "ArrayPattern",
"span": {
"start": 1169,
"end": 1177,
"ctxt": 0
},
"elements": [
{
"type": "Identifier",
"span": {
"start": 1170,
"end": 1172,
"ctxt": 0
},
"value": "c2",
"optional": false,
"typeAnnotation": null
},
{
"type": "Identifier",
"span": {
"start": 1174,
"end": 1176,
"ctxt": 0
},
"value": "c3",
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1177,
"end": 1195,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTupleType",
"span": {
"start": 1179,
"end": 1195,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 1180,
"end": 1186,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 1180,
"end": 1186,
"ctxt": 0
},
"kind": "string"
}
},
{
"type": "TsTupleElement",
"span": {
"start": 1188,
"end": 1194,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 1188,
"end": 1194,
"ctxt": 0
},
"kind": "string"
}
}
]
}
}
},
"init": {
"type": "ArrayExpression",
"span": {
"start": 1198,
"end": 1207,
"ctxt": 0
},
"elements": [
{
"spread": {
"start": 1199,
"end": 1202,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 1202,
"end": 1206,
"ctxt": 0
},
"value": "temp",
"optional": false
}
}
]
},
"definite": false
}
]
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 1220,
"end": 1262,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 1230,
"end": 1231,
"ctxt": 0
},
"value": "F",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 1232,
"end": 1262,
"ctxt": 0
},
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 1239,
"end": 1250,
"ctxt": 0
},
"value": "idx",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1242,
"end": 1250,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 1244,
"end": 1250,
"ctxt": 0
},
"kind": "number"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1251,
"end": 1260,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 1253,
"end": 1260,
"ctxt": 0
},
"kind": "boolean"
}
},
"readonly": false,
"static": false,
"span": {
"start": 1238,
"end": 1260,
"ctxt": 0
}
}
]
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 1273,
"end": 1276,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 1277,
"end": 1288,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 1277,
"end": 1288,
"ctxt": 0
},
"value": "idx",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1280,
"end": 1288,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 1282,
"end": 1288,
"ctxt": 0
},
"kind": "number"
}
}
}
}
],
"decorators": [],
"span": {
"start": 1264,
"end": 1331,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 1293,
"end": 1331,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 1299,
"end": 1329,
"ctxt": 0
},
"argument": {
"type": "ObjectExpression",
"span": {
"start": 1306,
"end": 1329,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "NumericLiteral",
"span": {
"start": 1316,
"end": 1317,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
},
"value": {
"type": "BooleanLiteral",
"span": {
"start": 1319,
"end": 1323,
"ctxt": 0
},
"value": true
}
}
]
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 1289,
"end": 1292,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 1291,
"end": 1292,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 1291,
"end": 1292,
"ctxt": 0
},
"value": "F",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 1332,
"end": 1358,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 1336,
"end": 1357,
"ctxt": 0
},
"id": {
"type": "ArrayPattern",
"span": {
"start": 1336,
"end": 1348,
"ctxt": 0
},
"elements": [
{
"type": "Identifier",
"span": {
"start": 1337,
"end": 1339,
"ctxt": 0
},
"value": "c4",
"optional": false,
"typeAnnotation": null
},
{
"type": "Identifier",
"span": {
"start": 1341,
"end": 1343,
"ctxt": 0
},
"value": "c5",
"optional": false,
"typeAnnotation": null
},
{
"type": "Identifier",
"span": {
"start": 1345,
"end": 1347,
"ctxt": 0
},
"value": "c6",
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 1351,
"end": 1357,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 1351,
"end": 1354,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 1355,
"end": 1356,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
}
],
"typeArguments": null
},
"definite": false
}
]
}
],
"interpreter": null
}