swc/crates/swc_ecma_parser/tests/tsc/controlFlowInstanceOfGuardPrimitives.json
2022-03-22 07:54:08 +00:00

694 lines
21 KiB
JSON

{
"type": "Script",
"span": {
"start": 0,
"end": 433,
"ctxt": 0
},
"body": [
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 9,
"end": 20,
"ctxt": 0
},
"value": "distinguish",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 21,
"end": 50,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 21,
"end": 50,
"ctxt": 0
},
"value": "thing",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 26,
"end": 50,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 28,
"end": 50,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 28,
"end": 34,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 37,
"end": 43,
"ctxt": 0
},
"kind": "number"
},
{
"type": "TsTypeReference",
"span": {
"start": 46,
"end": 50,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 46,
"end": 50,
"ctxt": 0
},
"value": "Date",
"optional": false
},
"typeParams": null
}
]
}
}
}
}
],
"decorators": [],
"span": {
"start": 0,
"end": 361,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 52,
"end": 361,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 58,
"end": 359,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 62,
"end": 85,
"ctxt": 0
},
"operator": "instanceof",
"left": {
"type": "Identifier",
"span": {
"start": 62,
"end": 67,
"ctxt": 0
},
"value": "thing",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 79,
"end": 85,
"ctxt": 0
},
"value": "Object",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 87,
"end": 162,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 97,
"end": 156,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 97,
"end": 155,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 97,
"end": 108,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 97,
"end": 104,
"ctxt": 0
},
"value": "console",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 105,
"end": 108,
"ctxt": 0
},
"value": "log",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "BinaryExpression",
"span": {
"start": 109,
"end": 154,
"ctxt": 0
},
"operator": "+",
"left": {
"type": "StringLiteral",
"span": {
"start": 109,
"end": 132,
"ctxt": 0
},
"value": "Aha!! It's a Date in ",
"raw": "\"Aha!! It's a Date in \""
},
"right": {
"type": "CallExpression",
"span": {
"start": 135,
"end": 154,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 135,
"end": 152,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 135,
"end": 140,
"ctxt": 0
},
"value": "thing",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 141,
"end": 152,
"ctxt": 0
},
"value": "getFullYear",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
}
}
],
"typeArguments": null
}
}
]
},
"alternate": {
"type": "IfStatement",
"span": {
"start": 168,
"end": 359,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 172,
"end": 197,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "UnaryExpression",
"span": {
"start": 172,
"end": 184,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 179,
"end": 184,
"ctxt": 0
},
"value": "thing",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 189,
"end": 197,
"ctxt": 0
},
"value": "string",
"raw": "'string'"
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 199,
"end": 276,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 209,
"end": 270,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 209,
"end": 269,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 209,
"end": 220,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 209,
"end": 216,
"ctxt": 0
},
"value": "console",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 217,
"end": 220,
"ctxt": 0
},
"value": "log",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "BinaryExpression",
"span": {
"start": 221,
"end": 268,
"ctxt": 0
},
"operator": "+",
"left": {
"type": "StringLiteral",
"span": {
"start": 221,
"end": 253,
"ctxt": 0
},
"value": "Aha!! It's a string of length ",
"raw": "\"Aha!! It's a string of length \""
},
"right": {
"type": "MemberExpression",
"span": {
"start": 256,
"end": 268,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 256,
"end": 261,
"ctxt": 0
},
"value": "thing",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 262,
"end": 268,
"ctxt": 0
},
"value": "length",
"optional": false
}
}
}
}
],
"typeArguments": null
}
}
]
},
"alternate": {
"type": "BlockStatement",
"span": {
"start": 282,
"end": 359,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 292,
"end": 353,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 292,
"end": 352,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 292,
"end": 303,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 292,
"end": 299,
"ctxt": 0
},
"value": "console",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 300,
"end": 303,
"ctxt": 0
},
"value": "log",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "BinaryExpression",
"span": {
"start": 304,
"end": 351,
"ctxt": 0
},
"operator": "+",
"left": {
"type": "StringLiteral",
"span": {
"start": 304,
"end": 328,
"ctxt": 0
},
"value": "Aha!! It's the number ",
"raw": "\"Aha!! It's the number \""
},
"right": {
"type": "CallExpression",
"span": {
"start": 331,
"end": 351,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 331,
"end": 348,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 331,
"end": 336,
"ctxt": 0
},
"value": "thing",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 337,
"end": 348,
"ctxt": 0
},
"value": "toPrecision",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 349,
"end": 350,
"ctxt": 0
},
"value": 3.0
}
}
],
"typeArguments": null
}
}
}
],
"typeArguments": null
}
}
]
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
{
"type": "ExpressionStatement",
"span": {
"start": 363,
"end": 387,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 363,
"end": 386,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 363,
"end": 374,
"ctxt": 0
},
"value": "distinguish",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NewExpression",
"span": {
"start": 375,
"end": 385,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 379,
"end": 383,
"ctxt": 0
},
"value": "Date",
"optional": false
},
"arguments": [],
"typeArguments": null
}
}
],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 388,
"end": 408,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 388,
"end": 407,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 388,
"end": 399,
"ctxt": 0
},
"value": "distinguish",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "StringLiteral",
"span": {
"start": 400,
"end": 406,
"ctxt": 0
},
"value": "beef",
"raw": "\"beef\""
}
}
],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 409,
"end": 433,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 409,
"end": 432,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 409,
"end": 420,
"ctxt": 0
},
"value": "distinguish",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 421,
"end": 431,
"ctxt": 0
},
"value": 3.14159265
}
}
],
"typeArguments": null
}
}
],
"interpreter": null
}