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

423 lines
10 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
2022-02-04 14:17:42 +03:00
"start": 1,
"end": 170,
"ctxt": 0
},
"body": [
{
"type": "TsTypeAliasDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 1,
"end": 20,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 6,
"end": 7,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 10,
"end": 19,
"ctxt": 0
},
"types": [
{
"type": "TsLiteralType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 10,
"end": 13,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 10,
"end": 13,
"ctxt": 0
},
"value": "a",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
{
"type": "TsLiteralType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 16,
"end": 19,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 16,
"end": 19,
"ctxt": 0
},
"value": "b",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
]
}
},
{
"type": "TsTypeAliasDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 21,
"end": 38,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 26,
"end": 27,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 30,
"end": 37,
"ctxt": 0
},
"types": [
{
"type": "TsArrayType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 30,
"end": 33,
"ctxt": 0
},
"elemType": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 30,
"end": 31,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 30,
"end": 31,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
},
{
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 36,
"end": 37,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 36,
"end": 37,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 40,
"end": 51,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
2022-02-04 14:17:42 +03:00
"start": 44,
"end": 50,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 44,
"end": 47,
"ctxt": 0
},
"value": "foo",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 47,
"end": 50,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 49,
"end": 50,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 49,
"end": 50,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "SwitchStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 52,
"end": 170,
"ctxt": 0
},
"discriminant": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 60,
"end": 63,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"cases": [
{
"type": "SwitchCase",
"span": {
2022-02-04 14:17:42 +03:00
"start": 71,
"end": 80,
"ctxt": 0
},
"test": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 76,
"end": 79,
"ctxt": 0
},
"value": "a",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"consequent": []
},
{
"type": "SwitchCase",
"span": {
2022-02-04 14:17:42 +03:00
"start": 85,
"end": 109,
"ctxt": 0
},
"test": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 90,
"end": 93,
"ctxt": 0
},
"value": "b",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"consequent": [
{
"type": "BreakStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 103,
"end": 109,
"ctxt": 0
},
"label": null
}
]
},
{
"type": "SwitchCase",
"span": {
2022-02-04 14:17:42 +03:00
"start": 114,
"end": 168,
"ctxt": 0
},
"test": null,
"consequent": [
{
"type": "ExpressionStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 131,
"end": 153,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 131,
"end": 152,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 131,
"end": 134,
"ctxt": 0
},
"value": "foo",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "MemberExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 137,
"end": 152,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 137,
"end": 149,
"ctxt": 0
},
"expression": {
"type": "TsAsExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 138,
"end": 148,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 138,
"end": 141,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"typeAnnotation": {
"type": "TsArrayType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 145,
"end": 148,
"ctxt": 0
},
"elemType": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 145,
"end": 146,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 145,
"end": 146,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
}
}
},
"property": {
"type": "Computed",
"span": {
2022-02-04 14:17:42 +03:00
"start": 149,
"end": 152,
"ctxt": 0
},
"expression": {
"type": "NumericLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 150,
"end": 151,
"ctxt": 0
},
"value": 0.0
}
}
}
}
},
{
"type": "BreakStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 162,
"end": 168,
"ctxt": 0
},
"label": null
}
]
}
]
}
],
"interpreter": null
}