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

408 lines
9.9 KiB
JSON

{
"type": "Script",
"span": {
"start": 2,
"end": 171,
"ctxt": 0
},
"body": [
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 2,
"end": 21,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 7,
"end": 8,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 11,
"end": 20,
"ctxt": 0
},
"types": [
{
"type": "TsLiteralType",
"span": {
"start": 11,
"end": 14,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
"start": 11,
"end": 14,
"ctxt": 0
},
"value": "a",
"raw": "\"a\""
}
},
{
"type": "TsLiteralType",
"span": {
"start": 17,
"end": 20,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
"start": 17,
"end": 20,
"ctxt": 0
},
"value": "b",
"raw": "\"b\""
}
}
]
}
},
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 22,
"end": 39,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 27,
"end": 28,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 31,
"end": 38,
"ctxt": 0
},
"types": [
{
"type": "TsArrayType",
"span": {
"start": 31,
"end": 34,
"ctxt": 0
},
"elemType": {
"type": "TsTypeReference",
"span": {
"start": 31,
"end": 32,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 31,
"end": 32,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
},
{
"type": "TsTypeReference",
"span": {
"start": 37,
"end": 38,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 37,
"end": 38,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 41,
"end": 52,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 45,
"end": 51,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 45,
"end": 48,
"ctxt": 0
},
"value": "foo",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 48,
"end": 51,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 50,
"end": 51,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 50,
"end": 51,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "SwitchStatement",
"span": {
"start": 53,
"end": 171,
"ctxt": 0
},
"discriminant": {
"type": "Identifier",
"span": {
"start": 61,
"end": 64,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"cases": [
{
"type": "SwitchCase",
"span": {
"start": 72,
"end": 81,
"ctxt": 0
},
"test": {
"type": "StringLiteral",
"span": {
"start": 77,
"end": 80,
"ctxt": 0
},
"value": "a",
"raw": "\"a\""
},
"consequent": []
},
{
"type": "SwitchCase",
"span": {
"start": 86,
"end": 110,
"ctxt": 0
},
"test": {
"type": "StringLiteral",
"span": {
"start": 91,
"end": 94,
"ctxt": 0
},
"value": "b",
"raw": "\"b\""
},
"consequent": [
{
"type": "BreakStatement",
"span": {
"start": 104,
"end": 110,
"ctxt": 0
},
"label": null
}
]
},
{
"type": "SwitchCase",
"span": {
"start": 115,
"end": 169,
"ctxt": 0
},
"test": null,
"consequent": [
{
"type": "ExpressionStatement",
"span": {
"start": 132,
"end": 154,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 132,
"end": 153,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 132,
"end": 135,
"ctxt": 0
},
"value": "foo",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "MemberExpression",
"span": {
"start": 138,
"end": 153,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 138,
"end": 150,
"ctxt": 0
},
"expression": {
"type": "TsAsExpression",
"span": {
"start": 139,
"end": 149,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 139,
"end": 142,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"typeAnnotation": {
"type": "TsArrayType",
"span": {
"start": 146,
"end": 149,
"ctxt": 0
},
"elemType": {
"type": "TsTypeReference",
"span": {
"start": 146,
"end": 147,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 146,
"end": 147,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
}
}
},
"property": {
"type": "Computed",
"span": {
"start": 150,
"end": 153,
"ctxt": 0
},
"expression": {
"type": "NumericLiteral",
"span": {
"start": 151,
"end": 152,
"ctxt": 0
},
"value": 0.0,
"raw": "0"
}
}
}
}
},
{
"type": "BreakStatement",
"span": {
"start": 163,
"end": 169,
"ctxt": 0
},
"label": null
}
]
}
]
}
],
"interpreter": null
}