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

835 lines
24 KiB
JSON

{
"type": "Script",
"span": {
"start": 53,
"end": 392,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 53,
"end": 104,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 67,
"end": 104,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 67,
"end": 70,
"ctxt": 0
},
"value": "bar",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 70,
"end": 104,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 72,
"end": 104,
"ctxt": 0
},
"types": [
{
"type": "TsTypeLiteral",
"span": {
"start": 72,
"end": 92,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 74,
"end": 90,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 74,
"end": 79,
"ctxt": 0
},
"value": "value",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 80,
"end": 90,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsArrayType",
"span": {
"start": 82,
"end": 90,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 82,
"end": 88,
"ctxt": 0
},
"kind": "number"
}
}
},
"typeParams": null
}
]
},
{
"type": "TsKeywordType",
"span": {
"start": 95,
"end": 104,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 115,
"end": 119,
"ctxt": 0
},
"value": "foo1",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 120,
"end": 149,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 120,
"end": 149,
"ctxt": 0
},
"value": "results",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 127,
"end": 149,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 129,
"end": 149,
"ctxt": 0
},
"types": [
{
"type": "TsArrayType",
"span": {
"start": 129,
"end": 137,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 129,
"end": 135,
"ctxt": 0
},
"kind": "number"
}
},
{
"type": "TsKeywordType",
"span": {
"start": 140,
"end": 149,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
}
}
],
"decorators": [],
"span": {
"start": 106,
"end": 200,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 151,
"end": 200,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 157,
"end": 198,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 157,
"end": 197,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 157,
"end": 192,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 157,
"end": 187,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 158,
"end": 186,
"ctxt": 0
},
"operator": "||=",
"left": {
"type": "Identifier",
"span": {
"start": 158,
"end": 165,
"ctxt": 0
},
"value": "results",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 170,
"end": 186,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "OptionalChainingExpression",
"span": {
"start": 170,
"end": 180,
"ctxt": 0
},
"questionDotToken": {
"start": 173,
"end": 174,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 170,
"end": 180,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 170,
"end": 173,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 175,
"end": 180,
"ctxt": 0
},
"value": "value",
"optional": false
}
}
},
"right": {
"type": "ArrayExpression",
"span": {
"start": 184,
"end": 186,
"ctxt": 0
},
"elements": []
}
}
}
},
"property": {
"type": "Identifier",
"span": {
"start": 188,
"end": 192,
"ctxt": 0
},
"value": "push",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 193,
"end": 196,
"ctxt": 0
},
"value": 100.0
}
}
],
"typeArguments": null
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 211,
"end": 215,
"ctxt": 0
},
"value": "foo2",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 216,
"end": 245,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 216,
"end": 245,
"ctxt": 0
},
"value": "results",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 223,
"end": 245,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 225,
"end": 245,
"ctxt": 0
},
"types": [
{
"type": "TsArrayType",
"span": {
"start": 225,
"end": 233,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 225,
"end": 231,
"ctxt": 0
},
"kind": "number"
}
},
{
"type": "TsKeywordType",
"span": {
"start": 236,
"end": 245,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
}
}
],
"decorators": [],
"span": {
"start": 202,
"end": 296,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 247,
"end": 296,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 253,
"end": 294,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 253,
"end": 293,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 253,
"end": 288,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 253,
"end": 283,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 254,
"end": 282,
"ctxt": 0
},
"operator": "??=",
"left": {
"type": "Identifier",
"span": {
"start": 254,
"end": 261,
"ctxt": 0
},
"value": "results",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 266,
"end": 282,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "OptionalChainingExpression",
"span": {
"start": 266,
"end": 276,
"ctxt": 0
},
"questionDotToken": {
"start": 269,
"end": 270,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 266,
"end": 276,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 266,
"end": 269,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 271,
"end": 276,
"ctxt": 0
},
"value": "value",
"optional": false
}
}
},
"right": {
"type": "ArrayExpression",
"span": {
"start": 280,
"end": 282,
"ctxt": 0
},
"elements": []
}
}
}
},
"property": {
"type": "Identifier",
"span": {
"start": 284,
"end": 288,
"ctxt": 0
},
"value": "push",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 289,
"end": 292,
"ctxt": 0
},
"value": 100.0
}
}
],
"typeArguments": null
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 307,
"end": 311,
"ctxt": 0
},
"value": "foo3",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 312,
"end": 341,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 312,
"end": 341,
"ctxt": 0
},
"value": "results",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 319,
"end": 341,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 321,
"end": 341,
"ctxt": 0
},
"types": [
{
"type": "TsArrayType",
"span": {
"start": 321,
"end": 329,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 321,
"end": 327,
"ctxt": 0
},
"kind": "number"
}
},
{
"type": "TsKeywordType",
"span": {
"start": 332,
"end": 341,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
}
}
],
"decorators": [],
"span": {
"start": 298,
"end": 392,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 343,
"end": 392,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 349,
"end": 390,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 349,
"end": 389,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 349,
"end": 384,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 349,
"end": 379,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 350,
"end": 378,
"ctxt": 0
},
"operator": "&&=",
"left": {
"type": "Identifier",
"span": {
"start": 350,
"end": 357,
"ctxt": 0
},
"value": "results",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 362,
"end": 378,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "OptionalChainingExpression",
"span": {
"start": 362,
"end": 372,
"ctxt": 0
},
"questionDotToken": {
"start": 365,
"end": 366,
"ctxt": 0
},
"expr": {
"type": "MemberExpression",
"span": {
"start": 362,
"end": 372,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 362,
"end": 365,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 367,
"end": 372,
"ctxt": 0
},
"value": "value",
"optional": false
}
}
},
"right": {
"type": "ArrayExpression",
"span": {
"start": 376,
"end": 378,
"ctxt": 0
},
"elements": []
}
}
}
},
"property": {
"type": "Identifier",
"span": {
"start": 380,
"end": 384,
"ctxt": 0
},
"value": "push",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 385,
"end": 388,
"ctxt": 0
},
"value": 100.0
}
}
],
"typeArguments": null
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
],
"interpreter": null
}