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

612 lines
15 KiB
JSON

{
"type": "Script",
"span": {
"start": 1,
"end": 370,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 1,
"end": 14,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 5,
"end": 13,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 5,
"end": 6,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 6,
"end": 13,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 8,
"end": 13,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
"start": 8,
"end": 13,
"ctxt": 0
},
"value": "foo",
"raw": "\"foo\""
}
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 15,
"end": 36,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 19,
"end": 35,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 19,
"end": 20,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 20,
"end": 35,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 22,
"end": 35,
"ctxt": 0
},
"types": [
{
"type": "TsLiteralType",
"span": {
"start": 22,
"end": 27,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
"start": 22,
"end": 27,
"ctxt": 0
},
"value": "foo",
"raw": "\"foo\""
}
},
{
"type": "TsLiteralType",
"span": {
"start": 30,
"end": 35,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
"start": 30,
"end": 35,
"ctxt": 0
},
"value": "bar",
"raw": "\"bar\""
}
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 56,
"end": 64,
"ctxt": 0
},
"value": "randBool",
"optional": false
},
"declare": true,
"params": [],
"decorators": [],
"span": {
"start": 39,
"end": 76,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 66,
"end": 75,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 68,
"end": 75,
"ctxt": 0
},
"kind": "boolean"
}
}
},
{
"type": "SwitchStatement",
"span": {
"start": 78,
"end": 370,
"ctxt": 0
},
"discriminant": {
"type": "Identifier",
"span": {
"start": 86,
"end": 87,
"ctxt": 0
},
"value": "y",
"optional": false
},
"cases": [
{
"type": "SwitchCase",
"span": {
"start": 95,
"end": 124,
"ctxt": 0
},
"test": {
"type": "SequenceExpression",
"span": {
"start": 100,
"end": 108,
"ctxt": 0
},
"expressions": [
{
"type": "StringLiteral",
"span": {
"start": 100,
"end": 105,
"ctxt": 0
},
"value": "foo",
"raw": "\"foo\""
},
{
"type": "Identifier",
"span": {
"start": 107,
"end": 108,
"ctxt": 0
},
"value": "x",
"optional": false
}
]
},
"consequent": [
{
"type": "BreakStatement",
"span": {
"start": 118,
"end": 124,
"ctxt": 0
},
"label": null
}
]
},
{
"type": "SwitchCase",
"span": {
"start": 129,
"end": 158,
"ctxt": 0
},
"test": {
"type": "SequenceExpression",
"span": {
"start": 134,
"end": 142,
"ctxt": 0
},
"expressions": [
{
"type": "Identifier",
"span": {
"start": 134,
"end": 135,
"ctxt": 0
},
"value": "x",
"optional": false
},
{
"type": "StringLiteral",
"span": {
"start": 137,
"end": 142,
"ctxt": 0
},
"value": "foo",
"raw": "\"foo\""
}
]
},
"consequent": [
{
"type": "BreakStatement",
"span": {
"start": 152,
"end": 158,
"ctxt": 0
},
"label": null
}
]
},
{
"type": "SwitchCase",
"span": {
"start": 163,
"end": 192,
"ctxt": 0
},
"test": {
"type": "SequenceExpression",
"span": {
"start": 168,
"end": 176,
"ctxt": 0
},
"expressions": [
{
"type": "Identifier",
"span": {
"start": 168,
"end": 169,
"ctxt": 0
},
"value": "x",
"optional": false
},
{
"type": "StringLiteral",
"span": {
"start": 171,
"end": 176,
"ctxt": 0
},
"value": "baz",
"raw": "\"baz\""
}
]
},
"consequent": [
{
"type": "BreakStatement",
"span": {
"start": 186,
"end": 192,
"ctxt": 0
},
"label": null
}
]
},
{
"type": "SwitchCase",
"span": {
"start": 197,
"end": 226,
"ctxt": 0
},
"test": {
"type": "SequenceExpression",
"span": {
"start": 202,
"end": 210,
"ctxt": 0
},
"expressions": [
{
"type": "StringLiteral",
"span": {
"start": 202,
"end": 207,
"ctxt": 0
},
"value": "baz",
"raw": "\"baz\""
},
{
"type": "Identifier",
"span": {
"start": 209,
"end": 210,
"ctxt": 0
},
"value": "x",
"optional": false
}
]
},
"consequent": [
{
"type": "BreakStatement",
"span": {
"start": 220,
"end": 226,
"ctxt": 0
},
"label": null
}
]
},
{
"type": "SwitchCase",
"span": {
"start": 231,
"end": 266,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 236,
"end": 250,
"ctxt": 0
},
"operator": "&&",
"left": {
"type": "StringLiteral",
"span": {
"start": 236,
"end": 241,
"ctxt": 0
},
"value": "baz",
"raw": "\"baz\""
},
"right": {
"type": "StringLiteral",
"span": {
"start": 245,
"end": 250,
"ctxt": 0
},
"value": "bar",
"raw": "\"bar\""
}
},
"consequent": [
{
"type": "BreakStatement",
"span": {
"start": 260,
"end": 266,
"ctxt": 0
},
"label": null
}
]
},
{
"type": "SwitchCase",
"span": {
"start": 271,
"end": 317,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 276,
"end": 301,
"ctxt": 0
},
"operator": "&&",
"left": {
"type": "StringLiteral",
"span": {
"start": 276,
"end": 281,
"ctxt": 0
},
"value": "baz",
"raw": "\"baz\""
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 285,
"end": 301,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 286,
"end": 300,
"ctxt": 0
},
"operator": "||",
"left": {
"type": "StringLiteral",
"span": {
"start": 286,
"end": 291,
"ctxt": 0
},
"value": "foo",
"raw": "\"foo\""
},
"right": {
"type": "StringLiteral",
"span": {
"start": 295,
"end": 300,
"ctxt": 0
},
"value": "bar",
"raw": "\"bar\""
}
}
}
},
"consequent": [
{
"type": "BreakStatement",
"span": {
"start": 311,
"end": 317,
"ctxt": 0
},
"label": null
}
]
},
{
"type": "SwitchCase",
"span": {
"start": 322,
"end": 368,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 327,
"end": 352,
"ctxt": 0
},
"operator": "&&",
"left": {
"type": "StringLiteral",
"span": {
"start": 327,
"end": 332,
"ctxt": 0
},
"value": "bar",
"raw": "\"bar\""
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 336,
"end": 352,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 337,
"end": 351,
"ctxt": 0
},
"operator": "||",
"left": {
"type": "StringLiteral",
"span": {
"start": 337,
"end": 342,
"ctxt": 0
},
"value": "baz",
"raw": "\"baz\""
},
"right": {
"type": "StringLiteral",
"span": {
"start": 346,
"end": 351,
"ctxt": 0
},
"value": "bar",
"raw": "\"bar\""
}
}
}
},
"consequent": [
{
"type": "BreakStatement",
"span": {
"start": 362,
"end": 368,
"ctxt": 0
},
"label": null
}
]
}
]
}
],
"interpreter": null
}