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

1274 lines
30 KiB
JSON
Raw Normal View History

{
"type": "Module",
"span": {
"start": 0,
"end": 714,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 0,
"end": 33,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 4,
"end": 32,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 4,
"end": 5,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 5,
"end": 32,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 7,
"end": 32,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 7,
"end": 13,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 16,
"end": 22,
"ctxt": 0
},
"kind": "number"
},
{
"type": "TsKeywordType",
"span": {
"start": 25,
"end": 32,
"ctxt": 0
},
"kind": "boolean"
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 34,
"end": 52,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 38,
"end": 51,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 38,
"end": 42,
"ctxt": 0
},
"value": "cond",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 42,
"end": 51,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 44,
"end": 51,
"ctxt": 0
},
"kind": "boolean"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 54,
"end": 74,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 54,
"end": 73,
"ctxt": 0
},
"operator": "||",
"left": {
"type": "ParenthesisExpression",
"span": {
"start": 54,
"end": 62,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 55,
"end": 61,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 55,
"end": 56,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 59,
"end": 61,
"ctxt": 0
},
"value": "",
"raw": "\"\""
}
}
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 66,
"end": 73,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 67,
"end": 72,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 67,
"end": 68,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 71,
"end": 72,
"ctxt": 0
},
"value": 0.0
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 75,
"end": 77,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 75,
"end": 76,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 98,
"end": 105,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 98,
"end": 104,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 98,
"end": 99,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 102,
"end": 104,
"ctxt": 0
},
"value": "",
"raw": "\"\""
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 106,
"end": 122,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 106,
"end": 121,
"ctxt": 0
},
"operator": "||",
"left": {
"type": "Identifier",
"span": {
"start": 106,
"end": 110,
"ctxt": 0
},
"value": "cond",
"optional": false
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 114,
"end": 121,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 115,
"end": 120,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 115,
"end": 116,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 119,
"end": 120,
"ctxt": 0
},
"value": 0.0
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 123,
"end": 125,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 123,
"end": 124,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
{
"type": "ExportDeclaration",
"span": {
"start": 146,
"end": 195,
"ctxt": 0
},
"declaration": {
"type": "TsInterfaceDeclaration",
"span": {
"start": 153,
"end": 195,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 163,
"end": 171,
"ctxt": 0
},
"value": "NodeList",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 172,
"end": 195,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 178,
"end": 193,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 178,
"end": 184,
"ctxt": 0
},
"value": "length",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 184,
"end": 192,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 186,
"end": 192,
"ctxt": 0
},
"kind": "number"
}
},
"typeParams": null
}
]
}
}
},
{
"type": "ExportDeclaration",
"span": {
"start": 197,
"end": 252,
"ctxt": 0
},
"declaration": {
"type": "TsInterfaceDeclaration",
"span": {
"start": 204,
"end": 252,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 214,
"end": 228,
"ctxt": 0
},
"value": "HTMLCollection",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 229,
"end": 252,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 235,
"end": 250,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 235,
"end": 241,
"ctxt": 0
},
"value": "length",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 241,
"end": 249,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 243,
"end": 249,
"ctxt": 0
},
"kind": "number"
}
},
"typeParams": null
}
]
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 271,
"end": 281,
"ctxt": 0
},
"value": "isNodeList",
"optional": false
},
"declare": true,
"params": [
{
"type": "Parameter",
"span": {
"start": 282,
"end": 296,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 282,
"end": 296,
"ctxt": 0
},
"value": "sourceObj",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 291,
"end": 296,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 293,
"end": 296,
"ctxt": 0
},
"kind": "any"
}
}
}
}
],
"decorators": [],
"span": {
"start": 254,
"end": 321,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 297,
"end": 320,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypePredicate",
"span": {
"start": 299,
"end": 320,
"ctxt": 0
},
"asserts": false,
"paramName": {
"type": "Identifier",
"span": {
"start": 299,
"end": 308,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 312,
"end": 320,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 312,
"end": 320,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 312,
"end": 320,
"ctxt": 0
},
"value": "NodeList",
"optional": false
},
"typeParams": null
}
}
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 339,
"end": 355,
"ctxt": 0
},
"value": "isHTMLCollection",
"optional": false
},
"declare": true,
"params": [
{
"type": "Parameter",
"span": {
"start": 356,
"end": 370,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 356,
"end": 370,
"ctxt": 0
},
"value": "sourceObj",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 365,
"end": 370,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 367,
"end": 370,
"ctxt": 0
},
"kind": "any"
}
}
}
}
],
"decorators": [],
"span": {
"start": 322,
"end": 401,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 371,
"end": 400,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypePredicate",
"span": {
"start": 373,
"end": 400,
"ctxt": 0
},
"asserts": false,
"paramName": {
"type": "Identifier",
"span": {
"start": 373,
"end": 382,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 386,
"end": 400,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 386,
"end": 400,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 386,
"end": 400,
"ctxt": 0
},
"value": "HTMLCollection",
"optional": false
},
"typeParams": null
}
}
}
}
},
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 403,
"end": 466,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 408,
"end": 423,
"ctxt": 0
},
"value": "EventTargetLike",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 426,
"end": 465,
"ctxt": 0
},
"types": [
{
"type": "TsTypeLiteral",
"span": {
"start": 426,
"end": 437,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 427,
"end": 436,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 427,
"end": 428,
"ctxt": 0
},
"value": "a",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 428,
"end": 436,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 430,
"end": 436,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
},
{
"type": "TsTypeReference",
"span": {
"start": 440,
"end": 454,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 440,
"end": 454,
"ctxt": 0
},
"value": "HTMLCollection",
"optional": false
},
"typeParams": null
},
{
"type": "TsTypeReference",
"span": {
"start": 457,
"end": 465,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 457,
"end": 465,
"ctxt": 0
},
"value": "NodeList",
"optional": false
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 468,
"end": 516,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 472,
"end": 515,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 472,
"end": 481,
"ctxt": 0
},
"value": "sourceObj",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 481,
"end": 498,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 483,
"end": 498,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 483,
"end": 498,
"ctxt": 0
},
"value": "EventTargetLike",
"optional": false
},
"typeParams": null
}
}
},
"init": {
"type": "TsTypeAssertion",
"span": {
"start": 501,
"end": 515,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 506,
"end": 515,
"ctxt": 0
},
"value": "undefined",
"optional": false
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 502,
"end": 505,
"ctxt": 0
},
"kind": "any"
}
},
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 517,
"end": 569,
"ctxt": 0
},
"test": {
"type": "CallExpression",
"span": {
"start": 521,
"end": 542,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 521,
"end": 531,
"ctxt": 0
},
"value": "isNodeList",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 532,
"end": 541,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
}
}
],
"typeArguments": null
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 544,
"end": 569,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 550,
"end": 567,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 550,
"end": 566,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 550,
"end": 559,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 560,
"end": 566,
"ctxt": 0
},
"value": "length",
"optional": false
}
}
}
]
},
"alternate": null
},
{
"type": "IfStatement",
"span": {
"start": 571,
"end": 629,
"ctxt": 0
},
"test": {
"type": "CallExpression",
"span": {
"start": 575,
"end": 602,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 575,
"end": 591,
"ctxt": 0
},
"value": "isHTMLCollection",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 592,
"end": 601,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
}
}
],
"typeArguments": null
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 604,
"end": 629,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 610,
"end": 627,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 610,
"end": 626,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 610,
"end": 619,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 620,
"end": 626,
"ctxt": 0
},
"value": "length",
"optional": false
}
}
}
]
},
"alternate": null
},
{
"type": "IfStatement",
"span": {
"start": 631,
"end": 714,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 635,
"end": 687,
"ctxt": 0
},
"operator": "||",
"left": {
"type": "CallExpression",
"span": {
"start": 635,
"end": 656,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 635,
"end": 645,
"ctxt": 0
},
"value": "isNodeList",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 646,
"end": 655,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
}
}
],
"typeArguments": null
},
"right": {
"type": "CallExpression",
"span": {
"start": 660,
"end": 687,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 660,
"end": 676,
"ctxt": 0
},
"value": "isHTMLCollection",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 677,
"end": 686,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
}
}
],
"typeArguments": null
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 689,
"end": 714,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 695,
"end": 712,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 695,
"end": 711,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 695,
"end": 704,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 705,
"end": 711,
"ctxt": 0
},
"value": "length",
"optional": false
}
}
}
]
},
"alternate": null
}
],
"interpreter": null
}