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

838 lines
24 KiB
JSON

{
"type": "Script",
"span": {
"start": 62,
"end": 401,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 62,
"end": 113,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 76,
"end": 113,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 76,
"end": 79,
"ctxt": 0
},
"value": "bar",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 79,
"end": 113,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 81,
"end": 113,
"ctxt": 0
},
"types": [
{
"type": "TsTypeLiteral",
"span": {
"start": 81,
"end": 101,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 83,
"end": 99,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 83,
"end": 88,
"ctxt": 0
},
"value": "value",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 89,
"end": 99,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsArrayType",
"span": {
"start": 91,
"end": 99,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 91,
"end": 97,
"ctxt": 0
},
"kind": "number"
}
}
},
"typeParams": null
}
]
},
{
"type": "TsKeywordType",
"span": {
"start": 104,
"end": 113,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 124,
"end": 128,
"ctxt": 0
},
"value": "foo1",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 129,
"end": 158,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 129,
"end": 158,
"ctxt": 0
},
"value": "results",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 136,
"end": 158,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 138,
"end": 158,
"ctxt": 0
},
"types": [
{
"type": "TsArrayType",
"span": {
"start": 138,
"end": 146,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 138,
"end": 144,
"ctxt": 0
},
"kind": "number"
}
},
{
"type": "TsKeywordType",
"span": {
"start": 149,
"end": 158,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
}
}
],
"decorators": [],
"span": {
"start": 115,
"end": 209,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 160,
"end": 209,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 166,
"end": 207,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 166,
"end": 206,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 166,
"end": 201,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 166,
"end": 196,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 167,
"end": 195,
"ctxt": 0
},
"operator": "||=",
"left": {
"type": "Identifier",
"span": {
"start": 167,
"end": 174,
"ctxt": 0
},
"value": "results",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 179,
"end": 195,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "OptionalChainingExpression",
"span": {
"start": 179,
"end": 189,
"ctxt": 0
},
"questionDotToken": {
"start": 182,
"end": 183,
"ctxt": 0
},
"base": {
"type": "MemberExpression",
"span": {
"start": 179,
"end": 189,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 179,
"end": 182,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 184,
"end": 189,
"ctxt": 0
},
"value": "value",
"optional": false
}
}
},
"right": {
"type": "ArrayExpression",
"span": {
"start": 193,
"end": 195,
"ctxt": 0
},
"elements": []
}
}
}
},
"property": {
"type": "Identifier",
"span": {
"start": 197,
"end": 201,
"ctxt": 0
},
"value": "push",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 202,
"end": 205,
"ctxt": 0
},
"value": 100.0,
"raw": "100"
}
}
],
"typeArguments": null
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 220,
"end": 224,
"ctxt": 0
},
"value": "foo2",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 225,
"end": 254,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 225,
"end": 254,
"ctxt": 0
},
"value": "results",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 232,
"end": 254,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 234,
"end": 254,
"ctxt": 0
},
"types": [
{
"type": "TsArrayType",
"span": {
"start": 234,
"end": 242,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 234,
"end": 240,
"ctxt": 0
},
"kind": "number"
}
},
{
"type": "TsKeywordType",
"span": {
"start": 245,
"end": 254,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
}
}
],
"decorators": [],
"span": {
"start": 211,
"end": 305,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 256,
"end": 305,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 262,
"end": 303,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 262,
"end": 302,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 262,
"end": 297,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 262,
"end": 292,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 263,
"end": 291,
"ctxt": 0
},
"operator": "??=",
"left": {
"type": "Identifier",
"span": {
"start": 263,
"end": 270,
"ctxt": 0
},
"value": "results",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 275,
"end": 291,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "OptionalChainingExpression",
"span": {
"start": 275,
"end": 285,
"ctxt": 0
},
"questionDotToken": {
"start": 278,
"end": 279,
"ctxt": 0
},
"base": {
"type": "MemberExpression",
"span": {
"start": 275,
"end": 285,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 275,
"end": 278,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 280,
"end": 285,
"ctxt": 0
},
"value": "value",
"optional": false
}
}
},
"right": {
"type": "ArrayExpression",
"span": {
"start": 289,
"end": 291,
"ctxt": 0
},
"elements": []
}
}
}
},
"property": {
"type": "Identifier",
"span": {
"start": 293,
"end": 297,
"ctxt": 0
},
"value": "push",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 298,
"end": 301,
"ctxt": 0
},
"value": 100.0,
"raw": "100"
}
}
],
"typeArguments": null
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 316,
"end": 320,
"ctxt": 0
},
"value": "foo3",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 321,
"end": 350,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 321,
"end": 350,
"ctxt": 0
},
"value": "results",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 328,
"end": 350,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 330,
"end": 350,
"ctxt": 0
},
"types": [
{
"type": "TsArrayType",
"span": {
"start": 330,
"end": 338,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 330,
"end": 336,
"ctxt": 0
},
"kind": "number"
}
},
{
"type": "TsKeywordType",
"span": {
"start": 341,
"end": 350,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
}
}
],
"decorators": [],
"span": {
"start": 307,
"end": 401,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 352,
"end": 401,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 358,
"end": 399,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 358,
"end": 398,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 358,
"end": 393,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 358,
"end": 388,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 359,
"end": 387,
"ctxt": 0
},
"operator": "&&=",
"left": {
"type": "Identifier",
"span": {
"start": 359,
"end": 366,
"ctxt": 0
},
"value": "results",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 371,
"end": 387,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "OptionalChainingExpression",
"span": {
"start": 371,
"end": 381,
"ctxt": 0
},
"questionDotToken": {
"start": 374,
"end": 375,
"ctxt": 0
},
"base": {
"type": "MemberExpression",
"span": {
"start": 371,
"end": 381,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 371,
"end": 374,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 376,
"end": 381,
"ctxt": 0
},
"value": "value",
"optional": false
}
}
},
"right": {
"type": "ArrayExpression",
"span": {
"start": 385,
"end": 387,
"ctxt": 0
},
"elements": []
}
}
}
},
"property": {
"type": "Identifier",
"span": {
"start": 389,
"end": 393,
"ctxt": 0
},
"value": "push",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 394,
"end": 397,
"ctxt": 0
},
"value": 100.0,
"raw": "100"
}
}
],
"typeArguments": null
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
],
"interpreter": null
}