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

930 lines
24 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
"start": 0,
2022-02-04 14:17:42 +03:00
"end": 487,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 0,
"end": 13,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 4,
"end": 12,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 4,
"end": 5,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 5,
"end": 12,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 7,
"end": 12,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
"start": 7,
"end": 12,
"ctxt": 0
},
"value": "foo",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 14,
"end": 35,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
2022-02-04 14:17:42 +03:00
"start": 18,
"end": 34,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 18,
"end": 19,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 19,
"end": 34,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 21,
"end": 34,
"ctxt": 0
},
"types": [
{
"type": "TsLiteralType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 21,
"end": 26,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 21,
"end": 26,
"ctxt": 0
},
"value": "foo",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
{
"type": "TsLiteralType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 29,
"end": 34,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 29,
"end": 34,
"ctxt": 0
},
"value": "bar",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 37,
"end": 50,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
2022-02-04 14:17:42 +03:00
"start": 41,
"end": 49,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 41,
"end": 42,
"ctxt": 0
},
"value": "z",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 42,
"end": 49,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 44,
"end": 49,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 44,
"end": 49,
"ctxt": 0
},
"value": "bar",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 69,
"end": 77,
"ctxt": 0
},
"value": "randBool",
"optional": false
},
"declare": true,
"params": [],
"decorators": [],
"span": {
2022-02-04 14:17:42 +03:00
"start": 52,
"end": 89,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 79,
"end": 88,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 81,
"end": 88,
"ctxt": 0
},
"kind": "boolean"
}
}
},
{
"type": "SwitchStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 91,
"end": 487,
"ctxt": 0
},
"discriminant": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 99,
"end": 100,
"ctxt": 0
},
"value": "x",
"optional": false
},
"cases": [
{
"type": "SwitchCase",
"span": {
2022-02-04 14:17:42 +03:00
"start": 108,
"end": 155,
"ctxt": 0
},
"test": {
"type": "ConditionalExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 113,
"end": 139,
"ctxt": 0
},
"test": {
"type": "CallExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 113,
"end": 123,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 113,
"end": 121,
"ctxt": 0
},
"value": "randBool",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"consequent": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 126,
"end": 131,
"ctxt": 0
},
"value": "foo",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"alternate": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 134,
"end": 139,
"ctxt": 0
},
"value": "baz",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"consequent": [
{
"type": "BreakStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 149,
"end": 155,
"ctxt": 0
},
"label": null
}
]
},
{
"type": "SwitchCase",
"span": {
2022-02-04 14:17:42 +03:00
"start": 160,
"end": 227,
"ctxt": 0
},
"test": {
"type": "ParenthesisExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 165,
"end": 211,
"ctxt": 0
},
"expression": {
"type": "ConditionalExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 166,
"end": 210,
"ctxt": 0
},
"test": {
"type": "CallExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 166,
"end": 176,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 166,
"end": 174,
"ctxt": 0
},
"value": "randBool",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"consequent": {
"type": "ParenthesisExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 179,
"end": 186,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 180,
"end": 185,
"ctxt": 0
},
"value": "bar",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"alternate": {
"type": "ConditionalExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 189,
"end": 210,
"ctxt": 0
},
"test": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 189,
"end": 194,
"ctxt": 0
},
"value": "baz",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"consequent": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 197,
"end": 202,
"ctxt": 0
},
"value": "bar",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"alternate": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 205,
"end": 210,
"ctxt": 0
},
"value": "baz",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
}
},
"consequent": [
{
"type": "BreakStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 221,
"end": 227,
"ctxt": 0
},
"label": null
}
]
},
{
"type": "SwitchCase",
"span": {
2022-02-04 14:17:42 +03:00
"start": 232,
"end": 262,
"ctxt": 0
},
"test": {
"type": "ParenthesisExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 237,
"end": 246,
"ctxt": 0
},
"expression": {
"type": "ParenthesisExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 238,
"end": 245,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 239,
"end": 244,
"ctxt": 0
},
"value": "bar",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
},
"consequent": [
{
"type": "BreakStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 256,
"end": 262,
"ctxt": 0
},
"label": null
}
]
},
{
"type": "SwitchCase",
"span": {
2022-02-04 14:17:42 +03:00
"start": 267,
"end": 325,
"ctxt": 0
},
"test": {
"type": "ParenthesisExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 272,
"end": 287,
"ctxt": 0
},
"expression": {
"type": "SequenceExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 273,
"end": 286,
"ctxt": 0
},
"expressions": [
{
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 273,
"end": 274,
"ctxt": 0
},
"value": "x",
"optional": false
},
{
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 276,
"end": 277,
"ctxt": 0
},
"value": "y",
"optional": false
},
{
"type": "ParenthesisExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 279,
"end": 286,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 280,
"end": 285,
"ctxt": 0
},
"value": "baz",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
]
}
},
"consequent": [
{
"type": "ExpressionStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 297,
"end": 299,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 297,
"end": 298,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
{
"type": "ExpressionStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 308,
"end": 310,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 308,
"end": 309,
"ctxt": 0
},
"value": "y",
"optional": false
}
},
{
"type": "BreakStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 319,
"end": 325,
"ctxt": 0
},
"label": null
}
]
},
{
"type": "SwitchCase",
"span": {
2022-02-04 14:17:42 +03:00
"start": 330,
"end": 371,
"ctxt": 0
},
"test": {
"type": "ParenthesisExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 335,
"end": 355,
"ctxt": 0
},
"expression": {
"type": "ParenthesisExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 336,
"end": 354,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 337,
"end": 353,
"ctxt": 0
},
"operator": "||",
"left": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 337,
"end": 342,
"ctxt": 0
},
"value": "foo",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"right": {
"type": "ParenthesisExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 346,
"end": 353,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 347,
"end": 352,
"ctxt": 0
},
"value": "bar",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
}
}
},
"consequent": [
{
"type": "BreakStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 365,
"end": 371,
"ctxt": 0
},
"label": null
}
]
},
{
"type": "SwitchCase",
"span": {
2022-02-04 14:17:42 +03:00
"start": 376,
"end": 417,
"ctxt": 0
},
"test": {
"type": "ParenthesisExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 381,
"end": 401,
"ctxt": 0
},
"expression": {
"type": "ParenthesisExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 382,
"end": 400,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 383,
"end": 399,
"ctxt": 0
},
"operator": "||",
"left": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 383,
"end": 388,
"ctxt": 0
},
"value": "bar",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"right": {
"type": "ParenthesisExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 392,
"end": 399,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 393,
"end": 398,
"ctxt": 0
},
"value": "baz",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
}
}
},
"consequent": [
{
"type": "BreakStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 411,
"end": 417,
"ctxt": 0
},
"label": null
}
]
},
{
"type": "SwitchCase",
"span": {
2022-02-04 14:17:42 +03:00
"start": 422,
"end": 438,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 427,
"end": 437,
"ctxt": 0
},
"operator": "||",
"left": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 427,
"end": 428,
"ctxt": 0
},
"value": "z",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 432,
"end": 437,
"ctxt": 0
},
"value": "baz",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"consequent": []
},
{
"type": "SwitchCase",
"span": {
2022-02-04 14:17:42 +03:00
"start": 443,
"end": 485,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 448,
"end": 458,
"ctxt": 0
},
"operator": "||",
"left": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 448,
"end": 453,
"ctxt": 0
},
"value": "baz",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"right": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 457,
"end": 458,
"ctxt": 0
},
"value": "z",
"optional": false
}
},
"consequent": [
{
"type": "ExpressionStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 468,
"end": 470,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 468,
"end": 469,
"ctxt": 0
},
"value": "z",
"optional": false
}
},
{
"type": "BreakStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 479,
"end": 485,
"ctxt": 0
},
"label": null
}
]
}
]
}
],
"interpreter": null
}