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

1533 lines
38 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
"start": 379,
"end": 1625,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 379,
"end": 407,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 383,
"end": 406,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 383,
"end": 389,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 385,
"end": 387,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 385,
"end": 387,
"ctxt": 0
},
"value": "a1",
"optional": false
},
"value": null
}
],
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 389,
"end": 394,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 391,
"end": 394,
"ctxt": 0
},
"kind": "any"
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 397,
"end": 406,
"ctxt": 0
},
"value": "undefined",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 408,
"end": 429,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 412,
"end": 428,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 412,
"end": 418,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 414,
"end": 416,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 414,
"end": 416,
"ctxt": 0
},
"value": "a2",
"optional": false
},
"value": null
}
],
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 418,
"end": 423,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 420,
"end": 423,
"ctxt": 0
},
"kind": "any"
}
}
},
"init": {
"type": "ObjectExpression",
"span": {
"start": 426,
"end": 428,
"ctxt": 0
},
"properties": []
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 653,
"end": 677,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 657,
"end": 676,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 657,
"end": 664,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 659,
"end": 661,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 659,
"end": 661,
"ctxt": 0
},
"value": "b1",
"optional": false
},
"value": null
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ObjectExpression",
"span": {
"start": 667,
"end": 676,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 669,
"end": 671,
"ctxt": 0
},
"value": "b1",
"optional": false
},
"value": {
"type": "NumericLiteral",
"span": {
"start": 672,
"end": 673,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
}
]
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 678,
"end": 746,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 682,
"end": 745,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 682,
"end": 718,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "Identifier",
"span": {
"start": 684,
"end": 686,
"ctxt": 0
},
"value": "b2",
"optional": false
},
"value": {
"type": "AssignmentPattern",
"span": {
"start": 688,
"end": 715,
"ctxt": 0
},
"left": {
"type": "ObjectPattern",
"span": {
"start": 688,
"end": 695,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 690,
"end": 693,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 690,
"end": 693,
"ctxt": 0
},
"value": "b21",
"optional": false
},
"value": null
}
],
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "ObjectExpression",
"span": {
"start": 698,
"end": 715,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 700,
"end": 703,
"ctxt": 0
},
"value": "b21",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 705,
"end": 713,
"ctxt": 0
},
"value": "string",
"raw": "\"string\""
}
}
]
},
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ObjectExpression",
"span": {
"start": 721,
"end": 745,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 723,
"end": 725,
"ctxt": 0
},
"value": "b2",
"optional": false
},
"value": {
"type": "ObjectExpression",
"span": {
"start": 727,
"end": 743,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 729,
"end": 732,
"ctxt": 0
},
"value": "b21",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 734,
"end": 741,
"ctxt": 0
},
"value": "world",
"raw": "\"world\""
}
}
]
}
}
]
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 747,
"end": 777,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 751,
"end": 776,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 751,
"end": 758,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "NumericLiteral",
"span": {
"start": 752,
"end": 753,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"value": {
"type": "Identifier",
"span": {
"start": 755,
"end": 757,
"ctxt": 0
},
"value": "b3",
"optional": false,
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ObjectExpression",
"span": {
"start": 761,
"end": 776,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "NumericLiteral",
"span": {
"start": 763,
"end": 764,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"value": {
"type": "StringLiteral",
"span": {
"start": 766,
"end": 774,
"ctxt": 0
},
"value": "string",
"raw": "\"string\""
}
}
]
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 778,
"end": 813,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 782,
"end": 812,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 782,
"end": 790,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 783,
"end": 789,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 783,
"end": 785,
"ctxt": 0
},
"value": "b4",
"optional": false
},
"value": {
"type": "NumericLiteral",
"span": {
"start": 788,
"end": 789,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
}
],
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 790,
"end": 795,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 792,
"end": 795,
"ctxt": 0
},
"kind": "any"
}
}
},
"init": {
"type": "ObjectExpression",
"span": {
"start": 798,
"end": 812,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 800,
"end": 802,
"ctxt": 0
},
"value": "b4",
"optional": false
},
"value": {
"type": "NumericLiteral",
"span": {
"start": 804,
"end": 810,
"ctxt": 0
},
"value": 100000.0,
"raw": "100000"
}
}
]
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 814,
"end": 852,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 818,
"end": 851,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 818,
"end": 833,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "Identifier",
"span": {
"start": 819,
"end": 821,
"ctxt": 0
},
"value": "b5",
"optional": false
},
"value": {
"type": "ObjectPattern",
"span": {
"start": 823,
"end": 830,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 825,
"end": 828,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 825,
"end": 828,
"ctxt": 0
},
"value": "b52",
"optional": false
},
"value": null
}
],
"optional": false,
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ObjectExpression",
"span": {
"start": 836,
"end": 851,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 838,
"end": 840,
"ctxt": 0
},
"value": "b5",
"optional": false
},
"value": {
"type": "ObjectExpression",
"span": {
"start": 842,
"end": 849,
"ctxt": 0
},
"properties": [
{
"type": "Identifier",
"span": {
"start": 844,
"end": 847,
"ctxt": 0
},
"value": "b52",
"optional": false
}
]
}
}
]
},
"definite": false
}
]
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 1084,
"end": 1127,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 1094,
"end": 1095,
"ctxt": 0
},
"value": "F",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 1096,
"end": 1127,
"ctxt": 0
},
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 1103,
"end": 1114,
"ctxt": 0
},
"value": "idx",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1106,
"end": 1114,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 1108,
"end": 1114,
"ctxt": 0
},
"kind": "number"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1115,
"end": 1124,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 1117,
"end": 1124,
"ctxt": 0
},
"kind": "boolean"
}
},
"readonly": false,
"static": false,
"span": {
"start": 1102,
"end": 1125,
"ctxt": 0
}
}
]
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 1138,
"end": 1141,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 1129,
"end": 1186,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 1147,
"end": 1186,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 1153,
"end": 1184,
"ctxt": 0
},
"argument": {
"type": "ObjectExpression",
"span": {
"start": 1160,
"end": 1183,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "NumericLiteral",
"span": {
"start": 1170,
"end": 1171,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"value": {
"type": "BooleanLiteral",
"span": {
"start": 1173,
"end": 1177,
"ctxt": 0
},
"value": true
}
}
]
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 1143,
"end": 1146,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 1145,
"end": 1146,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 1145,
"end": 1146,
"ctxt": 0
},
"value": "F",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 1197,
"end": 1200,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 1188,
"end": 1245,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 1206,
"end": 1245,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 1212,
"end": 1243,
"ctxt": 0
},
"argument": {
"type": "ObjectExpression",
"span": {
"start": 1219,
"end": 1242,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "NumericLiteral",
"span": {
"start": 1229,
"end": 1230,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
},
"value": {
"type": "BooleanLiteral",
"span": {
"start": 1232,
"end": 1236,
"ctxt": 0
},
"value": true
}
}
]
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 1202,
"end": 1205,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 1204,
"end": 1205,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 1204,
"end": 1205,
"ctxt": 0
},
"value": "F",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 1246,
"end": 1266,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 1250,
"end": 1265,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 1250,
"end": 1257,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "NumericLiteral",
"span": {
"start": 1251,
"end": 1252,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"value": {
"type": "Identifier",
"span": {
"start": 1254,
"end": 1256,
"ctxt": 0
},
"value": "c0",
"optional": false,
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 1260,
"end": 1265,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 1260,
"end": 1263,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 1267,
"end": 1287,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 1271,
"end": 1286,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 1271,
"end": 1278,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "NumericLiteral",
"span": {
"start": 1272,
"end": 1273,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"value": {
"type": "Identifier",
"span": {
"start": 1275,
"end": 1277,
"ctxt": 0
},
"value": "c1",
"optional": false,
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 1281,
"end": 1286,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 1281,
"end": 1284,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 1462,
"end": 1505,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 1472,
"end": 1474,
"ctxt": 0
},
"value": "F1",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 1475,
"end": 1505,
"ctxt": 0
},
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 1482,
"end": 1493,
"ctxt": 0
},
"value": "str",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1485,
"end": 1493,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 1487,
"end": 1493,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 1494,
"end": 1502,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 1496,
"end": 1502,
"ctxt": 0
},
"kind": "number"
}
},
"readonly": false,
"static": false,
"span": {
"start": 1481,
"end": 1503,
"ctxt": 0
}
}
]
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 1516,
"end": 1520,
"ctxt": 0
},
"value": "foo1",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 1507,
"end": 1568,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 1527,
"end": 1568,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 1533,
"end": 1566,
"ctxt": 0
},
"argument": {
"type": "ObjectExpression",
"span": {
"start": 1540,
"end": 1566,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "StringLiteral",
"span": {
"start": 1550,
"end": 1557,
"ctxt": 0
},
"value": "prop1",
"raw": "\"prop1\""
},
"value": {
"type": "NumericLiteral",
"span": {
"start": 1559,
"end": 1560,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
}
}
]
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 1522,
"end": 1526,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 1524,
"end": 1526,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 1524,
"end": 1526,
"ctxt": 0
},
"value": "F1",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 1570,
"end": 1597,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 1574,
"end": 1596,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 1574,
"end": 1587,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "StringLiteral",
"span": {
"start": 1575,
"end": 1582,
"ctxt": 0
},
"value": "prop1",
"raw": "\"prop1\""
},
"value": {
"type": "Identifier",
"span": {
"start": 1584,
"end": 1586,
"ctxt": 0
},
"value": "d1",
"optional": false,
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 1590,
"end": 1596,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 1590,
"end": 1594,
"ctxt": 0
},
"value": "foo1",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 1598,
"end": 1625,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 1602,
"end": 1624,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 1602,
"end": 1615,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "StringLiteral",
"span": {
"start": 1603,
"end": 1610,
"ctxt": 0
},
"value": "prop2",
"raw": "\"prop2\""
},
"value": {
"type": "Identifier",
"span": {
"start": 1612,
"end": 1614,
"ctxt": 0
},
"value": "d1",
"optional": false,
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 1618,
"end": 1624,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 1618,
"end": 1622,
"ctxt": 0
},
"value": "foo1",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
}
],
"interpreter": null
}