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

462 lines
12 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
2022-02-04 14:17:42 +03:00
"start": 1,
"end": 215,
"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",
"raw": "\"a\""
}
},
{
"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",
"raw": "\"b\""
}
}
]
}
},
{
"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": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 49,
"end": 50,
"ctxt": 0
},
"value": "f",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
2022-02-04 14:17:42 +03:00
"start": 51,
"end": 57,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 51,
"end": 57,
"ctxt": 0
},
"value": "foo",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 54,
"end": 57,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 56,
"end": 57,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 56,
"end": 57,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
],
"decorators": [],
"span": {
2022-02-04 14:17:42 +03:00
"start": 40,
"end": 215,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 59,
"end": 215,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 65,
"end": 213,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 69,
"end": 80,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 69,
"end": 72,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 77,
"end": 80,
"ctxt": 0
},
"value": "a",
"raw": "\"a\""
}
},
"consequent": {
"type": "BlockStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 82,
"end": 109,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 92,
"end": 103,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 99,
"end": 102,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
]
},
"alternate": {
"type": "IfStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 119,
"end": 213,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 123,
"end": 134,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 123,
"end": 126,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 131,
"end": 134,
"ctxt": 0
},
"value": "b",
"raw": "\"b\""
}
},
"consequent": {
"type": "BlockStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 136,
"end": 163,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 146,
"end": 157,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 153,
"end": 156,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
]
},
"alternate": {
"type": "BlockStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 173,
"end": 213,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 184,
"end": 207,
"ctxt": 0
},
"argument": {
"type": "MemberExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 191,
"end": 206,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 191,
"end": 203,
"ctxt": 0
},
"expression": {
"type": "TsAsExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 192,
"end": 202,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 192,
"end": 195,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"typeAnnotation": {
"type": "TsArrayType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 199,
"end": 202,
"ctxt": 0
},
"elemType": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 199,
"end": 200,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 199,
"end": 200,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
}
}
},
"property": {
"type": "Computed",
"span": {
2022-02-04 14:17:42 +03:00
"start": 203,
"end": 206,
"ctxt": 0
},
"expression": {
"type": "NumericLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 204,
"end": 205,
"ctxt": 0
},
"value": 0.0
}
}
}
}
]
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
],
"interpreter": null
}