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

704 lines
18 KiB
JSON

{
"type": "Script",
"span": {
"start": 18,
"end": 315,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 18,
"end": 54,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 32,
"end": 53,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 32,
"end": 33,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 33,
"end": 53,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 35,
"end": 53,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 35,
"end": 41,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 44,
"end": 53,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 55,
"end": 91,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 69,
"end": 90,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 69,
"end": 70,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 70,
"end": 90,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 72,
"end": 90,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 72,
"end": 78,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 81,
"end": 90,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 92,
"end": 128,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 106,
"end": 127,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 106,
"end": 107,
"ctxt": 0
},
"value": "c",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 107,
"end": 127,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 109,
"end": 127,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 109,
"end": 115,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 118,
"end": 127,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 130,
"end": 153,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 136,
"end": 152,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 136,
"end": 140,
"ctxt": 0
},
"value": "foo1",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ConditionalExpression",
"span": {
"start": 143,
"end": 152,
"ctxt": 0
},
"test": {
"type": "Identifier",
"span": {
"start": 143,
"end": 144,
"ctxt": 0
},
"value": "a",
"optional": false
},
"consequent": {
"type": "NumericLiteral",
"span": {
"start": 147,
"end": 148,
"ctxt": 0
},
"value": 1.0
},
"alternate": {
"type": "NumericLiteral",
"span": {
"start": 151,
"end": 152,
"ctxt": 0
},
"value": 2.0
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 154,
"end": 186,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 160,
"end": 185,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 160,
"end": 164,
"ctxt": 0
},
"value": "foo2",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ConditionalExpression",
"span": {
"start": 167,
"end": 185,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 167,
"end": 177,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "Identifier",
"span": {
"start": 167,
"end": 168,
"ctxt": 0
},
"value": "a",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 172,
"end": 177,
"ctxt": 0
},
"value": "foo",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"consequent": {
"type": "NumericLiteral",
"span": {
"start": 180,
"end": 181,
"ctxt": 0
},
"value": 1.0
},
"alternate": {
"type": "NumericLiteral",
"span": {
"start": 184,
"end": 185,
"ctxt": 0
},
"value": 2.0
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 187,
"end": 241,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 193,
"end": 240,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 193,
"end": 197,
"ctxt": 0
},
"value": "foo3",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ConditionalExpression",
"span": {
"start": 200,
"end": 240,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 200,
"end": 210,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "Identifier",
"span": {
"start": 200,
"end": 201,
"ctxt": 0
},
"value": "a",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 205,
"end": 210,
"ctxt": 0
},
"value": "foo",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"consequent": {
"type": "ParenthesisExpression",
"span": {
"start": 213,
"end": 225,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 214,
"end": 224,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "Identifier",
"span": {
"start": 214,
"end": 215,
"ctxt": 0
},
"value": "b",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 219,
"end": 224,
"ctxt": 0
},
"value": "bar",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
},
"alternate": {
"type": "ParenthesisExpression",
"span": {
"start": 228,
"end": 240,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 229,
"end": 239,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "Identifier",
"span": {
"start": 229,
"end": 230,
"ctxt": 0
},
"value": "c",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 234,
"end": 239,
"ctxt": 0
},
"value": "baz",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
}
},
"definite": false
}
]
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 252,
"end": 253,
"ctxt": 0
},
"value": "f",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 243,
"end": 315,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 257,
"end": 315,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 263,
"end": 313,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 269,
"end": 312,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 269,
"end": 273,
"ctxt": 0
},
"value": "foo4",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ConditionalExpression",
"span": {
"start": 276,
"end": 312,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 276,
"end": 286,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "Identifier",
"span": {
"start": 276,
"end": 277,
"ctxt": 0
},
"value": "a",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 281,
"end": 286,
"ctxt": 0
},
"value": "foo",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"consequent": {
"type": "BinaryExpression",
"span": {
"start": 289,
"end": 299,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "Identifier",
"span": {
"start": 289,
"end": 290,
"ctxt": 0
},
"value": "b",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 294,
"end": 299,
"ctxt": 0
},
"value": "bar",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"alternate": {
"type": "BinaryExpression",
"span": {
"start": 302,
"end": 312,
"ctxt": 0
},
"operator": "??",
"left": {
"type": "Identifier",
"span": {
"start": 302,
"end": 303,
"ctxt": 0
},
"value": "c",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 307,
"end": 312,
"ctxt": 0
},
"value": "baz",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
},
"definite": false
}
]
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
],
"interpreter": null
}