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

680 lines
17 KiB
JSON

{
"type": "Script",
"span": {
"start": 19,
"end": 316,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 19,
"end": 55,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 33,
"end": 54,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 33,
"end": 34,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 34,
"end": 54,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 36,
"end": 54,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 36,
"end": 42,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 45,
"end": 54,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 56,
"end": 92,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 70,
"end": 91,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 70,
"end": 71,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 71,
"end": 91,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 73,
"end": 91,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 73,
"end": 79,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 82,
"end": 91,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 93,
"end": 129,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 107,
"end": 128,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 107,
"end": 108,
"ctxt": 0
},
"value": "c",
"optional": false,
"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"
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 131,
"end": 154,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 137,
"end": 153,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 137,
"end": 141,
"ctxt": 0
},
"value": "foo1",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ConditionalExpression",
"span": {
"start": 144,
"end": 153,
"ctxt": 0
},
"test": {
"type": "Identifier",
"span": {
"start": 144,
"end": 145,
"ctxt": 0
},
"value": "a",
"optional": false
},
"consequent": {
"type": "NumericLiteral",
"span": {
"start": 148,
"end": 149,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"alternate": {
"type": "NumericLiteral",
"span": {
"start": 152,
"end": 153,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 155,
"end": 187,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 161,
"end": 186,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 161,
"end": 165,
"ctxt": 0
},
"value": "foo2",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ConditionalExpression",
"span": {
"start": 168,
"end": 186,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 168,
"end": 178,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "Identifier",
"span": {
"start": 168,
"end": 169,
"ctxt": 0
},
"value": "a",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 173,
"end": 178,
"ctxt": 0
},
"value": "foo",
"raw": "'foo'"
}
},
"consequent": {
"type": "NumericLiteral",
"span": {
"start": 181,
"end": 182,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"alternate": {
"type": "NumericLiteral",
"span": {
"start": 185,
"end": 186,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 188,
"end": 242,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 194,
"end": 241,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 194,
"end": 198,
"ctxt": 0
},
"value": "foo3",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ConditionalExpression",
"span": {
"start": 201,
"end": 241,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 201,
"end": 211,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "Identifier",
"span": {
"start": 201,
"end": 202,
"ctxt": 0
},
"value": "a",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 206,
"end": 211,
"ctxt": 0
},
"value": "foo",
"raw": "'foo'"
}
},
"consequent": {
"type": "ParenthesisExpression",
"span": {
"start": 214,
"end": 226,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 215,
"end": 225,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "Identifier",
"span": {
"start": 215,
"end": 216,
"ctxt": 0
},
"value": "b",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 220,
"end": 225,
"ctxt": 0
},
"value": "bar",
"raw": "'bar'"
}
}
},
"alternate": {
"type": "ParenthesisExpression",
"span": {
"start": 229,
"end": 241,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 230,
"end": 240,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "Identifier",
"span": {
"start": 230,
"end": 231,
"ctxt": 0
},
"value": "c",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 235,
"end": 240,
"ctxt": 0
},
"value": "baz",
"raw": "'baz'"
}
}
}
},
"definite": false
}
]
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 253,
"end": 254,
"ctxt": 0
},
"value": "f",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 244,
"end": 316,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 258,
"end": 316,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 264,
"end": 314,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 270,
"end": 313,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 270,
"end": 274,
"ctxt": 0
},
"value": "foo4",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ConditionalExpression",
"span": {
"start": 277,
"end": 313,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 277,
"end": 287,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "Identifier",
"span": {
"start": 277,
"end": 278,
"ctxt": 0
},
"value": "a",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 282,
"end": 287,
"ctxt": 0
},
"value": "foo",
"raw": "'foo'"
}
},
"consequent": {
"type": "BinaryExpression",
"span": {
"start": 290,
"end": 300,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "Identifier",
"span": {
"start": 290,
"end": 291,
"ctxt": 0
},
"value": "b",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 295,
"end": 300,
"ctxt": 0
},
"value": "bar",
"raw": "'bar'"
}
},
"alternate": {
"type": "BinaryExpression",
"span": {
"start": 303,
"end": 313,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "Identifier",
"span": {
"start": 303,
"end": 304,
"ctxt": 0
},
"value": "c",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 308,
"end": 313,
"ctxt": 0
},
"value": "baz",
"raw": "'baz'"
}
}
},
"definite": false
}
]
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
],
"interpreter": null
}