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

832 lines
20 KiB
JSON
Raw Normal View History

{
"type": "Module",
"span": {
"start": 0,
"end": 425,
"ctxt": 0
},
"body": [
{
"type": "TsModuleDeclaration",
"span": {
"start": 0,
"end": 72,
"ctxt": 0
},
"declare": true,
"global": true,
"id": {
"type": "Identifier",
"span": {
"start": 8,
"end": 14,
"ctxt": 0
},
"value": "global",
"optional": false
},
"body": {
"type": "TsModuleBlock",
"span": {
"start": 15,
"end": 72,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 21,
"end": 70,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 31,
"end": 39,
"ctxt": 0
},
"value": "Function",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 40,
"end": 70,
"ctxt": 0
},
"body": [
{
"type": "TsMethodSignature",
"span": {
"start": 50,
"end": 64,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 50,
"end": 53,
"ctxt": 0
},
"value": "now",
"optional": false
},
"computed": false,
"optional": false,
"params": [],
"typeAnn": {
"type": "TsTypeAnnotation",
"span": {
"start": 55,
"end": 63,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 57,
"end": 63,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
}
]
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 74,
"end": 131,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 74,
"end": 131,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 74,
"end": 96,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 74,
"end": 92,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 74,
"end": 82,
"ctxt": 0
},
"value": "Function",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 83,
"end": 92,
"ctxt": 0
},
"value": "prototype",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 93,
"end": 96,
"ctxt": 0
},
"value": "now",
"optional": false
}
},
"right": {
"type": "FunctionExpression",
"identifier": null,
"params": [],
"decorators": [],
"span": {
"start": 99,
"end": 131,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 111,
"end": 131,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 117,
"end": 129,
"ctxt": 0
},
"argument": {
"type": "StringLiteral",
"span": {
"start": 124,
"end": 129,
"ctxt": 0
},
"value": "now",
"raw": "\"now\""
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
}
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 139,
"end": 140,
"ctxt": 0
},
"value": "X",
"optional": false
},
"declare": false,
"span": {
"start": 133,
"end": 207,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassMethod",
"span": {
"start": 147,
"end": 185,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 154,
"end": 157,
"ctxt": 0
},
"value": "now",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 147,
"end": 185,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 160,
"end": 185,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 170,
"end": 179,
"ctxt": 0
},
"argument": {
"type": "ObjectExpression",
"span": {
"start": 177,
"end": 179,
"ctxt": 0
},
"properties": []
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "method",
"isStatic": true,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 191,
"end": 205,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 191,
"end": 194,
"ctxt": 0
},
"value": "why",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 191,
"end": 205,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 197,
"end": 205,
"ctxt": 0
},
"stmts": []
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
}
],
"superClass": null,
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 215,
"end": 216,
"ctxt": 0
},
"value": "Y",
"optional": false
},
"declare": false,
"span": {
"start": 209,
"end": 221,
"ctxt": 0
},
"decorators": [],
"body": [],
"superClass": null,
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "ExpressionStatement",
"span": {
"start": 223,
"end": 243,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 223,
"end": 243,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 223,
"end": 234,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 223,
"end": 230,
"ctxt": 0
},
"value": "console",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 231,
"end": 234,
"ctxt": 0
},
"value": "log",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "CallExpression",
"span": {
"start": 235,
"end": 242,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 235,
"end": 240,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 235,
"end": 236,
"ctxt": 0
},
"value": "X",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 237,
"end": 240,
"ctxt": 0
},
"value": "now",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
}
],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 265,
"end": 285,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 265,
"end": 285,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 265,
"end": 276,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 265,
"end": 272,
"ctxt": 0
},
"value": "console",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 273,
"end": 276,
"ctxt": 0
},
"value": "log",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "CallExpression",
"span": {
"start": 277,
"end": 284,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 277,
"end": 282,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 277,
"end": 278,
"ctxt": 0
},
"value": "Y",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 279,
"end": 282,
"ctxt": 0
},
"value": "now",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
}
],
"typeArguments": null
}
},
{
"type": "ExportDeclaration",
"span": {
"start": 308,
"end": 370,
"ctxt": 0
},
"declaration": {
"type": "VariableDeclaration",
"span": {
"start": 315,
"end": 370,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 321,
"end": 370,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 321,
"end": 322,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 322,
"end": 334,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 324,
"end": 334,
"ctxt": 0
},
"types": [
{
"type": "TsTypeReference",
"span": {
"start": 324,
"end": 325,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 324,
"end": 325,
"ctxt": 0
},
"value": "X",
"optional": false
},
"typeParams": null
},
{
"type": "TsKeywordType",
"span": {
"start": 328,
"end": 334,
"ctxt": 0
},
"kind": "number"
}
]
}
}
},
"init": {
"type": "ConditionalExpression",
"span": {
"start": 337,
"end": 370,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 337,
"end": 356,
"ctxt": 0
},
"operator": ">",
"left": {
"type": "CallExpression",
"span": {
"start": 337,
"end": 350,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 337,
"end": 348,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 337,
"end": 341,
"ctxt": 0
},
"value": "Math",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 342,
"end": 348,
"ctxt": 0
},
"value": "random",
"optional": false
}
},
"arguments": [],
"typeArguments": null
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 353,
"end": 356,
"ctxt": 0
},
"value": 0.5,
"raw": "0.5"
}
},
"consequent": {
"type": "NewExpression",
"span": {
"start": 359,
"end": 366,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 363,
"end": 364,
"ctxt": 0
},
"value": "X",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"alternate": {
"type": "NumericLiteral",
"span": {
"start": 369,
"end": 370,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
},
"definite": false
}
]
}
},
{
"type": "IfStatement",
"span": {
"start": 372,
"end": 425,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 376,
"end": 390,
"ctxt": 0
},
"operator": "instanceof",
"left": {
"type": "Identifier",
"span": {
"start": 376,
"end": 377,
"ctxt": 0
},
"value": "x",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 389,
"end": 390,
"ctxt": 0
},
"value": "X",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 392,
"end": 425,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 398,
"end": 405,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 398,
"end": 405,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 398,
"end": 403,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 398,
"end": 399,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 400,
"end": 403,
"ctxt": 0
},
"value": "why",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
}
]
},
"alternate": null
}
],
"interpreter": null
}