swc/crates/swc_ecma_parser/tests/tsc/stringLiteralCheckedInIf02.json
2022-04-05 12:46:35 +00:00

570 lines
14 KiB
JSON

{
"type": "Script",
"span": {
"start": 1,
"end": 216,
"ctxt": 0
},
"body": [
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 1,
"end": 20,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 6,
"end": 7,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 10,
"end": 19,
"ctxt": 0
},
"types": [
{
"type": "TsLiteralType",
"span": {
"start": 10,
"end": 13,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
"start": 10,
"end": 13,
"ctxt": 0
},
"value": "a",
"raw": "\"a\""
}
},
{
"type": "TsLiteralType",
"span": {
"start": 16,
"end": 19,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
"start": 16,
"end": 19,
"ctxt": 0
},
"value": "b",
"raw": "\"b\""
}
}
]
}
},
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 21,
"end": 38,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 26,
"end": 27,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 30,
"end": 37,
"ctxt": 0
},
"types": [
{
"type": "TsArrayType",
"span": {
"start": 30,
"end": 33,
"ctxt": 0
},
"elemType": {
"type": "TsTypeReference",
"span": {
"start": 30,
"end": 31,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 30,
"end": 31,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
},
{
"type": "TsTypeReference",
"span": {
"start": 36,
"end": 37,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 36,
"end": 37,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
]
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 49,
"end": 52,
"ctxt": 0
},
"value": "isS",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 53,
"end": 57,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 53,
"end": 57,
"ctxt": 0
},
"value": "t",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 54,
"end": 57,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 56,
"end": 57,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 56,
"end": 57,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
],
"decorators": [],
"span": {
"start": 40,
"end": 105,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 67,
"end": 105,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 73,
"end": 103,
"ctxt": 0
},
"argument": {
"type": "BinaryExpression",
"span": {
"start": 80,
"end": 102,
"ctxt": 0
},
"operator": "||",
"left": {
"type": "BinaryExpression",
"span": {
"start": 80,
"end": 89,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "Identifier",
"span": {
"start": 80,
"end": 81,
"ctxt": 0
},
"value": "t",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 86,
"end": 89,
"ctxt": 0
},
"value": "a",
"raw": "\"a\""
}
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 93,
"end": 102,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "Identifier",
"span": {
"start": 93,
"end": 94,
"ctxt": 0
},
"value": "t",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 99,
"end": 102,
"ctxt": 0
},
"value": "b",
"raw": "\"b\""
}
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 58,
"end": 66,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypePredicate",
"span": {
"start": 60,
"end": 66,
"ctxt": 0
},
"asserts": false,
"paramName": {
"type": "Identifier",
"span": {
"start": 60,
"end": 61,
"ctxt": 0
},
"value": "t",
"optional": false
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 65,
"end": 66,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 65,
"end": 66,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 65,
"end": 66,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
}
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 116,
"end": 117,
"ctxt": 0
},
"value": "f",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 118,
"end": 124,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 118,
"end": 124,
"ctxt": 0
},
"value": "foo",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 121,
"end": 124,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 123,
"end": 124,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 123,
"end": 124,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
],
"decorators": [],
"span": {
"start": 107,
"end": 216,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 126,
"end": 216,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 132,
"end": 214,
"ctxt": 0
},
"test": {
"type": "CallExpression",
"span": {
"start": 136,
"end": 144,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 136,
"end": 139,
"ctxt": 0
},
"value": "isS",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 140,
"end": 143,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
],
"typeArguments": null
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 146,
"end": 173,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 156,
"end": 167,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 163,
"end": 166,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
]
},
"alternate": {
"type": "BlockStatement",
"span": {
"start": 183,
"end": 214,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 194,
"end": 208,
"ctxt": 0
},
"argument": {
"type": "MemberExpression",
"span": {
"start": 201,
"end": 207,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 201,
"end": 204,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"property": {
"type": "Computed",
"span": {
"start": 204,
"end": 207,
"ctxt": 0
},
"expression": {
"type": "NumericLiteral",
"span": {
"start": 205,
"end": 206,
"ctxt": 0
},
"value": 0.0,
"raw": "0"
}
}
}
}
]
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
],
"interpreter": null
}