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

1490 lines
38 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
"start": 165,
"end": 1357,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 165,
"end": 188,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 169,
"end": 188,
"ctxt": 0
},
"id": {
"type": "ArrayPattern",
"span": {
"start": 169,
"end": 183,
"ctxt": 0
},
"elements": [
{
"type": "ArrayPattern",
"span": {
"start": 170,
"end": 174,
"ctxt": 0
},
"elements": [
{
"type": "Identifier",
"span": {
"start": 171,
"end": 173,
"ctxt": 0
},
"value": "a0",
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
},
{
"type": "ArrayPattern",
"span": {
"start": 176,
"end": 182,
"ctxt": 0
},
"elements": [
{
"type": "ArrayPattern",
"span": {
"start": 177,
"end": 181,
"ctxt": 0
},
"elements": [
{
"type": "Identifier",
"span": {
"start": 178,
"end": 180,
"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": 186,
"end": 188,
"ctxt": 0
},
"elements": []
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 206,
"end": 236,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 210,
"end": 236,
"ctxt": 0
},
"id": {
"type": "ArrayPattern",
"span": {
"start": 210,
"end": 224,
"ctxt": 0
},
"elements": [
{
"type": "ArrayPattern",
"span": {
"start": 211,
"end": 215,
"ctxt": 0
},
"elements": [
{
"type": "Identifier",
"span": {
"start": 212,
"end": 214,
"ctxt": 0
},
"value": "a2",
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
},
{
"type": "ArrayPattern",
"span": {
"start": 217,
"end": 223,
"ctxt": 0
},
"elements": [
{
"type": "ArrayPattern",
"span": {
"start": 218,
"end": 222,
"ctxt": 0
},
"elements": [
{
"type": "Identifier",
"span": {
"start": 219,
"end": 221,
"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": 227,
"end": 236,
"ctxt": 0
},
"value": "undefined",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 590,
"end": 653,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 594,
"end": 652,
"ctxt": 0
},
"id": {
"type": "ArrayPattern",
"span": {
"start": 594,
"end": 606,
"ctxt": 0
},
"elements": [
{
"type": "Identifier",
"span": {
"start": 595,
"end": 597,
"ctxt": 0
},
"value": "b0",
"optional": false,
"typeAnnotation": null
},
{
"type": "Identifier",
"span": {
"start": 599,
"end": 601,
"ctxt": 0
},
"value": "b1",
"optional": false,
"typeAnnotation": null
},
{
"type": "Identifier",
"span": {
"start": 603,
"end": 605,
"ctxt": 0
},
"value": "b2",
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 606,
"end": 633,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTupleType",
"span": {
"start": 608,
"end": 633,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 609,
"end": 615,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 609,
"end": 615,
"ctxt": 0
},
"kind": "number"
}
},
{
"type": "TsTupleElement",
"span": {
"start": 617,
"end": 624,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 617,
"end": 624,
"ctxt": 0
},
"kind": "boolean"
}
},
{
"type": "TsTupleElement",
"span": {
"start": 626,
"end": 632,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 626,
"end": 632,
"ctxt": 0
},
"kind": "string"
}
}
]
}
}
},
"init": {
"type": "ArrayExpression",
"span": {
"start": 636,
"end": 652,
"ctxt": 0
},
"elements": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 637,
"end": 638,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
},
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 640,
"end": 641,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
}
},
{
"spread": null,
"expression": {
"type": "StringLiteral",
"span": {
"start": 643,
"end": 651,
"ctxt": 0
},
"value": "string",
"raw": "\"string\""
}
}
]
},
"definite": false
}
]
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 664,
"end": 716,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 674,
"end": 675,
"ctxt": 0
},
"value": "J",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 684,
"end": 697,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 684,
"end": 689,
"ctxt": 0
},
"value": "Array",
"optional": false
},
"typeArguments": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 689,
"end": 697,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 690,
"end": 696,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 690,
"end": 696,
"ctxt": 0
},
"value": "Number",
"optional": false
},
"typeParams": null
}
]
}
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 698,
"end": 716,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 704,
"end": 714,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
"start": 704,
"end": 705,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 705,
"end": 713,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 707,
"end": 713,
"ctxt": 0
},
"kind": "number"
}
},
"typeParams": null
}
]
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 727,
"end": 730,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 718,
"end": 787,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 736,
"end": 787,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 742,
"end": 785,
"ctxt": 0
},
"argument": {
"type": "TsTypeAssertion",
"span": {
"start": 749,
"end": 784,
"ctxt": 0
},
"expression": {
"type": "ArrayExpression",
"span": {
"start": 775,
"end": 784,
"ctxt": 0
},
"elements": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 776,
"end": 777,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
},
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 779,
"end": 780,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
}
},
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 782,
"end": 783,
"ctxt": 0
},
"value": 3.0,
"raw": "3"
}
}
]
},
"typeAnnotation": {
"type": "TsTupleType",
"span": {
"start": 750,
"end": 774,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 751,
"end": 757,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 751,
"end": 757,
"ctxt": 0
},
"kind": "number"
}
},
{
"type": "TsTupleElement",
"span": {
"start": 759,
"end": 765,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 759,
"end": 765,
"ctxt": 0
},
"kind": "number"
}
},
{
"type": "TsTupleElement",
"span": {
"start": 767,
"end": 773,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 767,
"end": 773,
"ctxt": 0
},
"kind": "number"
}
}
]
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 732,
"end": 735,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 734,
"end": 735,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 734,
"end": 735,
"ctxt": 0
},
"value": "J",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 788,
"end": 824,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 792,
"end": 823,
"ctxt": 0
},
"id": {
"type": "ArrayPattern",
"span": {
"start": 792,
"end": 815,
"ctxt": 0
},
"elements": [
{
"type": "AssignmentPattern",
"span": {
"start": 793,
"end": 806,
"ctxt": 0
},
"left": {
"type": "Identifier",
"span": {
"start": 793,
"end": 795,
"ctxt": 0
},
"value": "b3",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 798,
"end": 806,
"ctxt": 0
},
"value": "string",
"raw": "\"string\""
},
"typeAnnotation": null
},
{
"type": "Identifier",
"span": {
"start": 808,
"end": 810,
"ctxt": 0
},
"value": "b4",
"optional": false,
"typeAnnotation": null
},
{
"type": "Identifier",
"span": {
"start": 812,
"end": 814,
"ctxt": 0
},
"value": "b5",
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 818,
"end": 823,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 818,
"end": 821,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 1089,
"end": 1109,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 1093,
"end": 1109,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 1093,
"end": 1097,
"ctxt": 0
},
"value": "temp",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ArrayExpression",
"span": {
"start": 1100,
"end": 1109,
"ctxt": 0
},
"elements": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 1101,
"end": 1102,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
},
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 1104,
"end": 1105,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
}
},
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 1107,
"end": 1108,
"ctxt": 0
},
"value": 3.0,
"raw": "3"
}
}
]
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 1110,
"end": 1153,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 1114,
"end": 1152,
"ctxt": 0
},
"id": {
"type": "ArrayPattern",
"span": {
"start": 1114,
"end": 1122,
"ctxt": 0
},
"elements": [
{
"type": "Identifier",
"span": {
"start": 1115,
"end": 1117,
"ctxt": 0
},
"value": "c0",
"optional": false,
"typeAnnotation": null
},
{
"type": "Identifier",
"span": {
"start": 1119,
"end": 1121,
"ctxt": 0
},
"value": "c1",
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1122,
"end": 1140,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTupleType",
"span": {
"start": 1124,
"end": 1140,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 1125,
"end": 1131,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 1125,
"end": 1131,
"ctxt": 0
},
"kind": "number"
}
},
{
"type": "TsTupleElement",
"span": {
"start": 1133,
"end": 1139,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 1133,
"end": 1139,
"ctxt": 0
},
"kind": "number"
}
}
]
}
}
},
"init": {
"type": "ArrayExpression",
"span": {
"start": 1143,
"end": 1152,
"ctxt": 0
},
"elements": [
{
"spread": {
"start": 1144,
"end": 1147,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 1147,
"end": 1151,
"ctxt": 0
},
"value": "temp",
"optional": false
}
}
]
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 1164,
"end": 1207,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 1168,
"end": 1206,
"ctxt": 0
},
"id": {
"type": "ArrayPattern",
"span": {
"start": 1168,
"end": 1176,
"ctxt": 0
},
"elements": [
{
"type": "Identifier",
"span": {
"start": 1169,
"end": 1171,
"ctxt": 0
},
"value": "c2",
"optional": false,
"typeAnnotation": null
},
{
"type": "Identifier",
"span": {
"start": 1173,
"end": 1175,
"ctxt": 0
},
"value": "c3",
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1176,
"end": 1194,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTupleType",
"span": {
"start": 1178,
"end": 1194,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 1179,
"end": 1185,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 1179,
"end": 1185,
"ctxt": 0
},
"kind": "string"
}
},
{
"type": "TsTupleElement",
"span": {
"start": 1187,
"end": 1193,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 1187,
"end": 1193,
"ctxt": 0
},
"kind": "string"
}
}
]
}
}
},
"init": {
"type": "ArrayExpression",
"span": {
"start": 1197,
"end": 1206,
"ctxt": 0
},
"elements": [
{
"spread": {
"start": 1198,
"end": 1201,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 1201,
"end": 1205,
"ctxt": 0
},
"value": "temp",
"optional": false
}
}
]
},
"definite": false
}
]
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 1219,
"end": 1261,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 1229,
"end": 1230,
"ctxt": 0
},
"value": "F",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 1231,
"end": 1261,
"ctxt": 0
},
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 1238,
"end": 1249,
"ctxt": 0
},
"value": "idx",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1241,
"end": 1249,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 1243,
"end": 1249,
"ctxt": 0
},
"kind": "number"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1250,
"end": 1259,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 1252,
"end": 1259,
"ctxt": 0
},
"kind": "boolean"
}
},
"readonly": false,
"static": false,
"span": {
"start": 1237,
"end": 1259,
"ctxt": 0
}
}
]
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 1272,
"end": 1275,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 1276,
"end": 1287,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 1276,
"end": 1287,
"ctxt": 0
},
"value": "idx",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1279,
"end": 1287,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 1281,
"end": 1287,
"ctxt": 0
},
"kind": "number"
}
}
}
}
],
"decorators": [],
"span": {
"start": 1263,
"end": 1330,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 1292,
"end": 1330,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 1298,
"end": 1328,
"ctxt": 0
},
"argument": {
"type": "ObjectExpression",
"span": {
"start": 1305,
"end": 1328,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "NumericLiteral",
"span": {
"start": 1315,
"end": 1316,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
},
"value": {
"type": "BooleanLiteral",
"span": {
"start": 1318,
"end": 1322,
"ctxt": 0
},
"value": true
}
}
]
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 1288,
"end": 1291,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 1290,
"end": 1291,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 1290,
"end": 1291,
"ctxt": 0
},
"value": "F",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 1331,
"end": 1357,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 1335,
"end": 1356,
"ctxt": 0
},
"id": {
"type": "ArrayPattern",
"span": {
"start": 1335,
"end": 1347,
"ctxt": 0
},
"elements": [
{
"type": "Identifier",
"span": {
"start": 1336,
"end": 1338,
"ctxt": 0
},
"value": "c4",
"optional": false,
"typeAnnotation": null
},
{
"type": "Identifier",
"span": {
"start": 1340,
"end": 1342,
"ctxt": 0
},
"value": "c5",
"optional": false,
"typeAnnotation": null
},
{
"type": "Identifier",
"span": {
"start": 1344,
"end": 1346,
"ctxt": 0
},
"value": "c6",
"optional": false,
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 1350,
"end": 1356,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 1350,
"end": 1353,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 1354,
"end": 1355,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
}
],
"typeArguments": null
},
"definite": false
}
]
}
],
"interpreter": null
}