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

1533 lines
38 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
"start": 363,
"end": 1609,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 363,
"end": 391,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 367,
"end": 390,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 367,
"end": 373,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 369,
"end": 371,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 369,
"end": 371,
"ctxt": 0
},
"value": "a1",
"optional": false
},
"value": null
}
],
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 373,
"end": 378,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 375,
"end": 378,
"ctxt": 0
},
"kind": "any"
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 381,
"end": 390,
"ctxt": 0
},
"value": "undefined",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 392,
"end": 413,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 396,
"end": 412,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 396,
"end": 402,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 398,
"end": 400,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 398,
"end": 400,
"ctxt": 0
},
"value": "a2",
"optional": false
},
"value": null
}
],
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 402,
"end": 407,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 404,
"end": 407,
"ctxt": 0
},
"kind": "any"
}
}
},
"init": {
"type": "ObjectExpression",
"span": {
"start": 410,
"end": 412,
"ctxt": 0
},
"properties": []
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 637,
"end": 661,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 641,
"end": 660,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 641,
"end": 648,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 643,
"end": 645,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 643,
"end": 645,
"ctxt": 0
},
"value": "b1",
"optional": false
},
"value": null
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ObjectExpression",
"span": {
"start": 651,
"end": 660,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 653,
"end": 655,
"ctxt": 0
},
"value": "b1",
"optional": false
},
"value": {
"type": "NumericLiteral",
"span": {
"start": 656,
"end": 657,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
}
]
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 662,
"end": 730,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 666,
"end": 729,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 666,
"end": 702,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "Identifier",
"span": {
"start": 668,
"end": 670,
"ctxt": 0
},
"value": "b2",
"optional": false
},
"value": {
"type": "AssignmentPattern",
"span": {
"start": 672,
"end": 699,
"ctxt": 0
},
"left": {
"type": "ObjectPattern",
"span": {
"start": 672,
"end": 679,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 674,
"end": 677,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 674,
"end": 677,
"ctxt": 0
},
"value": "b21",
"optional": false
},
"value": null
}
],
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "ObjectExpression",
"span": {
"start": 682,
"end": 699,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 684,
"end": 687,
"ctxt": 0
},
"value": "b21",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 689,
"end": 697,
"ctxt": 0
},
"value": "string",
"raw": "\"string\""
}
}
]
},
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ObjectExpression",
"span": {
"start": 705,
"end": 729,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 707,
"end": 709,
"ctxt": 0
},
"value": "b2",
"optional": false
},
"value": {
"type": "ObjectExpression",
"span": {
"start": 711,
"end": 727,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 713,
"end": 716,
"ctxt": 0
},
"value": "b21",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 718,
"end": 725,
"ctxt": 0
},
"value": "world",
"raw": "\"world\""
}
}
]
}
}
]
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 731,
"end": 761,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 735,
"end": 760,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 735,
"end": 742,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "NumericLiteral",
"span": {
"start": 736,
"end": 737,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"value": {
"type": "Identifier",
"span": {
"start": 739,
"end": 741,
"ctxt": 0
},
"value": "b3",
"optional": false,
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ObjectExpression",
"span": {
"start": 745,
"end": 760,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "NumericLiteral",
"span": {
"start": 747,
"end": 748,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"value": {
"type": "StringLiteral",
"span": {
"start": 750,
"end": 758,
"ctxt": 0
},
"value": "string",
"raw": "\"string\""
}
}
]
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 762,
"end": 797,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 766,
"end": 796,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 766,
"end": 774,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 767,
"end": 773,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 767,
"end": 769,
"ctxt": 0
},
"value": "b4",
"optional": false
},
"value": {
"type": "NumericLiteral",
"span": {
"start": 772,
"end": 773,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
}
],
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 774,
"end": 779,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 776,
"end": 779,
"ctxt": 0
},
"kind": "any"
}
}
},
"init": {
"type": "ObjectExpression",
"span": {
"start": 782,
"end": 796,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 784,
"end": 786,
"ctxt": 0
},
"value": "b4",
"optional": false
},
"value": {
"type": "NumericLiteral",
"span": {
"start": 788,
"end": 794,
"ctxt": 0
},
"value": 100000.0,
"raw": "100000"
}
}
]
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 798,
"end": 836,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 802,
"end": 835,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 802,
"end": 817,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "Identifier",
"span": {
"start": 803,
"end": 805,
"ctxt": 0
},
"value": "b5",
"optional": false
},
"value": {
"type": "ObjectPattern",
"span": {
"start": 807,
"end": 814,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 809,
"end": 812,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 809,
"end": 812,
"ctxt": 0
},
"value": "b52",
"optional": false
},
"value": null
}
],
"optional": false,
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ObjectExpression",
"span": {
"start": 820,
"end": 835,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 822,
"end": 824,
"ctxt": 0
},
"value": "b5",
"optional": false
},
"value": {
"type": "ObjectExpression",
"span": {
"start": 826,
"end": 833,
"ctxt": 0
},
"properties": [
{
"type": "Identifier",
"span": {
"start": 828,
"end": 831,
"ctxt": 0
},
"value": "b52",
"optional": false
}
]
}
}
]
},
"definite": false
}
]
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 1068,
"end": 1111,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 1078,
"end": 1079,
"ctxt": 0
},
"value": "F",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 1080,
"end": 1111,
"ctxt": 0
},
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 1087,
"end": 1098,
"ctxt": 0
},
"value": "idx",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1090,
"end": 1098,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 1092,
"end": 1098,
"ctxt": 0
},
"kind": "number"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1099,
"end": 1108,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 1101,
"end": 1108,
"ctxt": 0
},
"kind": "boolean"
}
},
"readonly": false,
"static": false,
"span": {
"start": 1086,
"end": 1109,
"ctxt": 0
}
}
]
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 1122,
"end": 1125,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 1113,
"end": 1170,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 1131,
"end": 1170,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 1137,
"end": 1168,
"ctxt": 0
},
"argument": {
"type": "ObjectExpression",
"span": {
"start": 1144,
"end": 1167,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "NumericLiteral",
"span": {
"start": 1154,
"end": 1155,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"value": {
"type": "BooleanLiteral",
"span": {
"start": 1157,
"end": 1161,
"ctxt": 0
},
"value": true
}
}
]
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 1127,
"end": 1130,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 1129,
"end": 1130,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 1129,
"end": 1130,
"ctxt": 0
},
"value": "F",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 1181,
"end": 1184,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 1172,
"end": 1229,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 1190,
"end": 1229,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 1196,
"end": 1227,
"ctxt": 0
},
"argument": {
"type": "ObjectExpression",
"span": {
"start": 1203,
"end": 1226,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "NumericLiteral",
"span": {
"start": 1213,
"end": 1214,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
},
"value": {
"type": "BooleanLiteral",
"span": {
"start": 1216,
"end": 1220,
"ctxt": 0
},
"value": true
}
}
]
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 1186,
"end": 1189,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 1188,
"end": 1189,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 1188,
"end": 1189,
"ctxt": 0
},
"value": "F",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 1230,
"end": 1250,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 1234,
"end": 1249,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 1234,
"end": 1241,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "NumericLiteral",
"span": {
"start": 1235,
"end": 1236,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"value": {
"type": "Identifier",
"span": {
"start": 1238,
"end": 1240,
"ctxt": 0
},
"value": "c0",
"optional": false,
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 1244,
"end": 1249,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 1244,
"end": 1247,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 1251,
"end": 1271,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 1255,
"end": 1270,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 1255,
"end": 1262,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "NumericLiteral",
"span": {
"start": 1256,
"end": 1257,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"value": {
"type": "Identifier",
"span": {
"start": 1259,
"end": 1261,
"ctxt": 0
},
"value": "c1",
"optional": false,
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 1265,
"end": 1270,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 1265,
"end": 1268,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 1446,
"end": 1489,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 1456,
"end": 1458,
"ctxt": 0
},
"value": "F1",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 1459,
"end": 1489,
"ctxt": 0
},
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 1466,
"end": 1477,
"ctxt": 0
},
"value": "str",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1469,
"end": 1477,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 1471,
"end": 1477,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1478,
"end": 1486,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 1480,
"end": 1486,
"ctxt": 0
},
"kind": "number"
}
},
"readonly": false,
"static": false,
"span": {
"start": 1465,
"end": 1487,
"ctxt": 0
}
}
]
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 1500,
"end": 1504,
"ctxt": 0
},
"value": "foo1",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 1491,
"end": 1552,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 1511,
"end": 1552,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 1517,
"end": 1550,
"ctxt": 0
},
"argument": {
"type": "ObjectExpression",
"span": {
"start": 1524,
"end": 1550,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "StringLiteral",
"span": {
"start": 1534,
"end": 1541,
"ctxt": 0
},
"value": "prop1",
"raw": "\"prop1\""
},
"value": {
"type": "NumericLiteral",
"span": {
"start": 1543,
"end": 1544,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
}
}
]
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 1506,
"end": 1510,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 1508,
"end": 1510,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 1508,
"end": 1510,
"ctxt": 0
},
"value": "F1",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 1554,
"end": 1581,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 1558,
"end": 1580,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 1558,
"end": 1571,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "StringLiteral",
"span": {
"start": 1559,
"end": 1566,
"ctxt": 0
},
"value": "prop1",
"raw": "\"prop1\""
},
"value": {
"type": "Identifier",
"span": {
"start": 1568,
"end": 1570,
"ctxt": 0
},
"value": "d1",
"optional": false,
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 1574,
"end": 1580,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 1574,
"end": 1578,
"ctxt": 0
},
"value": "foo1",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 1582,
"end": 1609,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 1586,
"end": 1608,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 1586,
"end": 1599,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "StringLiteral",
"span": {
"start": 1587,
"end": 1594,
"ctxt": 0
},
"value": "prop2",
"raw": "\"prop2\""
},
"value": {
"type": "Identifier",
"span": {
"start": 1596,
"end": 1598,
"ctxt": 0
},
"value": "d1",
"optional": false,
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 1602,
"end": 1608,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 1602,
"end": 1606,
"ctxt": 0
},
"value": "foo1",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
}
],
"interpreter": null
}