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

665 lines
16 KiB
JSON

{
"type": "Script",
"span": {
"start": 1,
"end": 453,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 1,
"end": 20,
"ctxt": 0
},
"kind": "var",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 13,
"end": 19,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 13,
"end": 14,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 14,
"end": 19,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 16,
"end": 19,
"ctxt": 0
},
"kind": "any"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 22,
"end": 162,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 26,
"end": 47,
"ctxt": 0
},
"operator": "instanceof",
"left": {
"type": "Identifier",
"span": {
"start": 26,
"end": 27,
"ctxt": 0
},
"value": "x",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 39,
"end": 47,
"ctxt": 0
},
"value": "Function",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 49,
"end": 162,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 111,
"end": 115,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 111,
"end": 114,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 111,
"end": 112,
"ctxt": 0
},
"value": "x",
"optional": false
},
"arguments": [],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 120,
"end": 131,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 120,
"end": 130,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 120,
"end": 121,
"ctxt": 0
},
"value": "x",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 122,
"end": 123,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
},
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 125,
"end": 126,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
}
},
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 128,
"end": 129,
"ctxt": 0
},
"value": 3.0,
"raw": "3"
}
}
],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 136,
"end": 148,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 136,
"end": 147,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 136,
"end": 137,
"ctxt": 0
},
"value": "x",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "StringLiteral",
"span": {
"start": 138,
"end": 146,
"ctxt": 0
},
"value": "hello!",
"raw": "\"hello!\""
}
}
],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 153,
"end": 160,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 153,
"end": 159,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 153,
"end": 154,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 155,
"end": 159,
"ctxt": 0
},
"value": "prop",
"optional": false
}
}
}
]
},
"alternate": null
},
{
"type": "IfStatement",
"span": {
"start": 164,
"end": 271,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 168,
"end": 187,
"ctxt": 0
},
"operator": "instanceof",
"left": {
"type": "Identifier",
"span": {
"start": 168,
"end": 169,
"ctxt": 0
},
"value": "x",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 181,
"end": 187,
"ctxt": 0
},
"value": "Object",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 189,
"end": 271,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 249,
"end": 260,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 249,
"end": 259,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 249,
"end": 257,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 249,
"end": 250,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 251,
"end": 257,
"ctxt": 0
},
"value": "method",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 265,
"end": 269,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 265,
"end": 268,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 265,
"end": 266,
"ctxt": 0
},
"value": "x",
"optional": false
},
"arguments": [],
"typeArguments": null
}
}
]
},
"alternate": null
},
{
"type": "IfStatement",
"span": {
"start": 273,
"end": 390,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 277,
"end": 295,
"ctxt": 0
},
"operator": "instanceof",
"left": {
"type": "Identifier",
"span": {
"start": 277,
"end": 278,
"ctxt": 0
},
"value": "x",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 290,
"end": 295,
"ctxt": 0
},
"value": "Error",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 297,
"end": 390,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 364,
"end": 374,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 364,
"end": 373,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 364,
"end": 365,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 366,
"end": 373,
"ctxt": 0
},
"value": "message",
"optional": false
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 379,
"end": 388,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 379,
"end": 387,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 379,
"end": 380,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 381,
"end": 387,
"ctxt": 0
},
"value": "mesage",
"optional": false
}
}
}
]
},
"alternate": null
},
{
"type": "IfStatement",
"span": {
"start": 392,
"end": 453,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 396,
"end": 413,
"ctxt": 0
},
"operator": "instanceof",
"left": {
"type": "Identifier",
"span": {
"start": 396,
"end": 397,
"ctxt": 0
},
"value": "x",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 409,
"end": 413,
"ctxt": 0
},
"value": "Date",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 415,
"end": 453,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 421,
"end": 433,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 421,
"end": 432,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 421,
"end": 430,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 421,
"end": 422,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 423,
"end": 430,
"ctxt": 0
},
"value": "getDate",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 438,
"end": 451,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 438,
"end": 450,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 438,
"end": 448,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 438,
"end": 439,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 440,
"end": 448,
"ctxt": 0
},
"value": "getHuors",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
}
]
},
"alternate": null
}
],
"interpreter": null
}