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

832 lines
20 KiB
JSON

{
"type": "Module",
"span": {
"start": 1,
"end": 426,
"ctxt": 0
},
"body": [
{
"type": "TsModuleDeclaration",
"span": {
"start": 1,
"end": 73,
"ctxt": 0
},
"declare": true,
"global": true,
"id": {
"type": "Identifier",
"span": {
"start": 9,
"end": 15,
"ctxt": 0
},
"value": "global",
"optional": false
},
"body": {
"type": "TsModuleBlock",
"span": {
"start": 16,
"end": 73,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 22,
"end": 71,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 32,
"end": 40,
"ctxt": 0
},
"value": "Function",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 41,
"end": 71,
"ctxt": 0
},
"body": [
{
"type": "TsMethodSignature",
"span": {
"start": 51,
"end": 65,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 51,
"end": 54,
"ctxt": 0
},
"value": "now",
"optional": false
},
"computed": false,
"optional": false,
"params": [],
"typeAnn": {
"type": "TsTypeAnnotation",
"span": {
"start": 56,
"end": 64,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 58,
"end": 64,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
}
]
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 75,
"end": 132,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 75,
"end": 132,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 75,
"end": 97,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 75,
"end": 93,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 75,
"end": 83,
"ctxt": 0
},
"value": "Function",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 84,
"end": 93,
"ctxt": 0
},
"value": "prototype",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 94,
"end": 97,
"ctxt": 0
},
"value": "now",
"optional": false
}
},
"right": {
"type": "FunctionExpression",
"identifier": null,
"params": [],
"decorators": [],
"span": {
"start": 100,
"end": 132,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 112,
"end": 132,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 118,
"end": 130,
"ctxt": 0
},
"argument": {
"type": "StringLiteral",
"span": {
"start": 125,
"end": 130,
"ctxt": 0
},
"value": "now",
"raw": "\"now\""
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
}
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 140,
"end": 141,
"ctxt": 0
},
"value": "X",
"optional": false
},
"declare": false,
"span": {
"start": 134,
"end": 208,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassMethod",
"span": {
"start": 148,
"end": 186,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 155,
"end": 158,
"ctxt": 0
},
"value": "now",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 148,
"end": 186,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 161,
"end": 186,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 171,
"end": 180,
"ctxt": 0
},
"argument": {
"type": "ObjectExpression",
"span": {
"start": 178,
"end": 180,
"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": 192,
"end": 206,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 192,
"end": 195,
"ctxt": 0
},
"value": "why",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 192,
"end": 206,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 198,
"end": 206,
"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": 216,
"end": 217,
"ctxt": 0
},
"value": "Y",
"optional": false
},
"declare": false,
"span": {
"start": 210,
"end": 222,
"ctxt": 0
},
"decorators": [],
"body": [],
"superClass": null,
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "ExpressionStatement",
"span": {
"start": 224,
"end": 244,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 224,
"end": 244,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 224,
"end": 235,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 224,
"end": 231,
"ctxt": 0
},
"value": "console",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 232,
"end": 235,
"ctxt": 0
},
"value": "log",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "CallExpression",
"span": {
"start": 236,
"end": 243,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 236,
"end": 241,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 236,
"end": 237,
"ctxt": 0
},
"value": "X",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 238,
"end": 241,
"ctxt": 0
},
"value": "now",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
}
],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 266,
"end": 286,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 266,
"end": 286,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 266,
"end": 277,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 266,
"end": 273,
"ctxt": 0
},
"value": "console",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 274,
"end": 277,
"ctxt": 0
},
"value": "log",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "CallExpression",
"span": {
"start": 278,
"end": 285,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 278,
"end": 283,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 278,
"end": 279,
"ctxt": 0
},
"value": "Y",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 280,
"end": 283,
"ctxt": 0
},
"value": "now",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
}
],
"typeArguments": null
}
},
{
"type": "ExportDeclaration",
"span": {
"start": 309,
"end": 371,
"ctxt": 0
},
"declaration": {
"type": "VariableDeclaration",
"span": {
"start": 316,
"end": 371,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 322,
"end": 371,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 322,
"end": 323,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 323,
"end": 335,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 325,
"end": 335,
"ctxt": 0
},
"types": [
{
"type": "TsTypeReference",
"span": {
"start": 325,
"end": 326,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 325,
"end": 326,
"ctxt": 0
},
"value": "X",
"optional": false
},
"typeParams": null
},
{
"type": "TsKeywordType",
"span": {
"start": 329,
"end": 335,
"ctxt": 0
},
"kind": "number"
}
]
}
}
},
"init": {
"type": "ConditionalExpression",
"span": {
"start": 338,
"end": 371,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 338,
"end": 357,
"ctxt": 0
},
"operator": ">",
"left": {
"type": "CallExpression",
"span": {
"start": 338,
"end": 351,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 338,
"end": 349,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 338,
"end": 342,
"ctxt": 0
},
"value": "Math",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 343,
"end": 349,
"ctxt": 0
},
"value": "random",
"optional": false
}
},
"arguments": [],
"typeArguments": null
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 354,
"end": 357,
"ctxt": 0
},
"value": 0.5,
"raw": "0.5"
}
},
"consequent": {
"type": "NewExpression",
"span": {
"start": 360,
"end": 367,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 364,
"end": 365,
"ctxt": 0
},
"value": "X",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"alternate": {
"type": "NumericLiteral",
"span": {
"start": 370,
"end": 371,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
},
"definite": false
}
]
}
},
{
"type": "IfStatement",
"span": {
"start": 373,
"end": 426,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 377,
"end": 391,
"ctxt": 0
},
"operator": "instanceof",
"left": {
"type": "Identifier",
"span": {
"start": 377,
"end": 378,
"ctxt": 0
},
"value": "x",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 390,
"end": 391,
"ctxt": 0
},
"value": "X",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 393,
"end": 426,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 399,
"end": 406,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 399,
"end": 406,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 399,
"end": 404,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 399,
"end": 400,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 401,
"end": 404,
"ctxt": 0
},
"value": "why",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
}
]
},
"alternate": null
}
],
"interpreter": null
}