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

699 lines
20 KiB
JSON

{
"type": "Script",
"span": {
"start": 19,
"end": 265,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 19,
"end": 87,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 33,
"end": 86,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 33,
"end": 34,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 34,
"end": 86,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 36,
"end": 86,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 38,
"end": 60,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 38,
"end": 39,
"ctxt": 0
},
"value": "p",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 39,
"end": 59,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 41,
"end": 59,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 41,
"end": 47,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 50,
"end": 59,
"ctxt": 0
},
"kind": "undefined"
}
]
}
},
"typeParams": null
},
{
"type": "TsMethodSignature",
"span": {
"start": 61,
"end": 84,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 61,
"end": 62,
"ctxt": 0
},
"value": "m",
"optional": false
},
"computed": false,
"optional": false,
"params": [],
"typeAnn": {
"type": "TsTypeAnnotation",
"span": {
"start": 64,
"end": 84,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 66,
"end": 84,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 66,
"end": 72,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 75,
"end": 84,
"ctxt": 0
},
"kind": "undefined"
}
]
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 88,
"end": 156,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 102,
"end": 155,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 102,
"end": 103,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 103,
"end": 155,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 105,
"end": 155,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 107,
"end": 129,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 107,
"end": 108,
"ctxt": 0
},
"value": "p",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 108,
"end": 128,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 110,
"end": 128,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 110,
"end": 116,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 119,
"end": 128,
"ctxt": 0
},
"kind": "undefined"
}
]
}
},
"typeParams": null
},
{
"type": "TsMethodSignature",
"span": {
"start": 130,
"end": 153,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 130,
"end": 131,
"ctxt": 0
},
"value": "m",
"optional": false
},
"computed": false,
"optional": false,
"params": [],
"typeAnn": {
"type": "TsTypeAnnotation",
"span": {
"start": 133,
"end": 153,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 135,
"end": 153,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 135,
"end": 141,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 144,
"end": 153,
"ctxt": 0
},
"kind": "undefined"
}
]
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 158,
"end": 186,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 164,
"end": 185,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 164,
"end": 166,
"ctxt": 0
},
"value": "n1",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "BinaryExpression",
"span": {
"start": 169,
"end": 185,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "MemberExpression",
"span": {
"start": 169,
"end": 172,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 169,
"end": 170,
"ctxt": 0
},
"value": "a",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 171,
"end": 172,
"ctxt": 0
},
"value": "p",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 176,
"end": 185,
"ctxt": 0
},
"value": "default",
"raw": "\"default\""
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 187,
"end": 217,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 193,
"end": 216,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 193,
"end": 195,
"ctxt": 0
},
"value": "n2",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "BinaryExpression",
"span": {
"start": 198,
"end": 216,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "CallExpression",
"span": {
"start": 198,
"end": 203,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 198,
"end": 201,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 198,
"end": 199,
"ctxt": 0
},
"value": "a",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 200,
"end": 201,
"ctxt": 0
},
"value": "m",
"optional": false
}
},
"arguments": [],
"typeArguments": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 207,
"end": 216,
"ctxt": 0
},
"value": "default",
"raw": "\"default\""
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 218,
"end": 264,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 224,
"end": 263,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 224,
"end": 226,
"ctxt": 0
},
"value": "n3",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "BinaryExpression",
"span": {
"start": 229,
"end": 263,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "BinaryExpression",
"span": {
"start": 229,
"end": 250,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "BinaryExpression",
"span": {
"start": 229,
"end": 241,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "CallExpression",
"span": {
"start": 229,
"end": 234,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 229,
"end": 232,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 229,
"end": 230,
"ctxt": 0
},
"value": "a",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 231,
"end": 232,
"ctxt": 0
},
"value": "m",
"optional": false
}
},
"arguments": [],
"typeArguments": null
},
"right": {
"type": "MemberExpression",
"span": {
"start": 238,
"end": 241,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 238,
"end": 239,
"ctxt": 0
},
"value": "b",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 240,
"end": 241,
"ctxt": 0
},
"value": "p",
"optional": false
}
}
},
"right": {
"type": "CallExpression",
"span": {
"start": 245,
"end": 250,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 245,
"end": 248,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 245,
"end": 246,
"ctxt": 0
},
"value": "b",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 247,
"end": 248,
"ctxt": 0
},
"value": "m",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 254,
"end": 263,
"ctxt": 0
},
"value": "default",
"raw": "\"default\""
}
},
"definite": false
}
]
},
{
"type": "EmptyStatement",
"span": {
"start": 264,
"end": 265,
"ctxt": 0
}
}
],
"interpreter": null
}