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

666 lines
16 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
"start": 0,
"end": 452,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 0,
"end": 19,
"ctxt": 0
},
"kind": "var",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 12,
"end": 18,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 12,
"end": 13,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 13,
"end": 18,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 15,
"end": 18,
"ctxt": 0
},
"kind": "any"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 21,
"end": 161,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 25,
"end": 46,
"ctxt": 0
},
"operator": "instanceof",
"left": {
"type": "Identifier",
"span": {
"start": 25,
"end": 26,
"ctxt": 0
},
"value": "x",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 38,
"end": 46,
"ctxt": 0
},
"value": "Function",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 48,
"end": 161,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 110,
"end": 114,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 110,
"end": 113,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 110,
"end": 111,
"ctxt": 0
},
"value": "x",
"optional": false
},
"arguments": [],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 119,
"end": 130,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 119,
"end": 129,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 119,
"end": 120,
"ctxt": 0
},
"value": "x",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 121,
"end": 122,
"ctxt": 0
},
"value": 1.0
}
},
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 124,
"end": 125,
"ctxt": 0
},
"value": 2.0
}
},
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 127,
"end": 128,
"ctxt": 0
},
"value": 3.0
}
}
],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 135,
"end": 147,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 135,
"end": 146,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 135,
"end": 136,
"ctxt": 0
},
"value": "x",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "StringLiteral",
"span": {
"start": 137,
"end": 145,
"ctxt": 0
},
"value": "hello!",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 152,
"end": 159,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 152,
"end": 158,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 152,
"end": 153,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 154,
"end": 158,
"ctxt": 0
},
"value": "prop",
"optional": false
}
}
}
]
},
"alternate": null
},
{
"type": "IfStatement",
"span": {
"start": 163,
"end": 270,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 167,
"end": 186,
"ctxt": 0
},
"operator": "instanceof",
"left": {
"type": "Identifier",
"span": {
"start": 167,
"end": 168,
"ctxt": 0
},
"value": "x",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 180,
"end": 186,
"ctxt": 0
},
"value": "Object",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 188,
"end": 270,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 248,
"end": 259,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 248,
"end": 258,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 248,
"end": 256,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 248,
"end": 249,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 250,
"end": 256,
"ctxt": 0
},
"value": "method",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 264,
"end": 268,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 264,
"end": 267,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 264,
"end": 265,
"ctxt": 0
},
"value": "x",
"optional": false
},
"arguments": [],
"typeArguments": null
}
}
]
},
"alternate": null
},
{
"type": "IfStatement",
"span": {
"start": 272,
"end": 389,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 276,
"end": 294,
"ctxt": 0
},
"operator": "instanceof",
"left": {
"type": "Identifier",
"span": {
"start": 276,
"end": 277,
"ctxt": 0
},
"value": "x",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 289,
"end": 294,
"ctxt": 0
},
"value": "Error",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 296,
"end": 389,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 363,
"end": 373,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 363,
"end": 372,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 363,
"end": 364,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 365,
"end": 372,
"ctxt": 0
},
"value": "message",
"optional": false
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 378,
"end": 387,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 378,
"end": 386,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 378,
"end": 379,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 380,
"end": 386,
"ctxt": 0
},
"value": "mesage",
"optional": false
}
}
}
]
},
"alternate": null
},
{
"type": "IfStatement",
"span": {
"start": 391,
"end": 452,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 395,
"end": 412,
"ctxt": 0
},
"operator": "instanceof",
"left": {
"type": "Identifier",
"span": {
"start": 395,
"end": 396,
"ctxt": 0
},
"value": "x",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 408,
"end": 412,
"ctxt": 0
},
"value": "Date",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 414,
"end": 452,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 420,
"end": 432,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 420,
"end": 431,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 420,
"end": 429,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 420,
"end": 421,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 422,
"end": 429,
"ctxt": 0
},
"value": "getDate",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 437,
"end": 450,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 437,
"end": 449,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 437,
"end": 447,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 437,
"end": 438,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 439,
"end": 447,
"ctxt": 0
},
"value": "getHuors",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
}
]
},
"alternate": null
}
],
"interpreter": null
}