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

1276 lines
30 KiB
JSON

{
"type": "Module",
"span": {
"start": 1,
"end": 715,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 1,
"end": 34,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 5,
"end": 33,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 5,
"end": 6,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 6,
"end": 33,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 8,
"end": 33,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 8,
"end": 14,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 17,
"end": 23,
"ctxt": 0
},
"kind": "number"
},
{
"type": "TsKeywordType",
"span": {
"start": 26,
"end": 33,
"ctxt": 0
},
"kind": "boolean"
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 35,
"end": 53,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 39,
"end": 52,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 39,
"end": 43,
"ctxt": 0
},
"value": "cond",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 43,
"end": 52,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 45,
"end": 52,
"ctxt": 0
},
"kind": "boolean"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 55,
"end": 75,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 55,
"end": 74,
"ctxt": 0
},
"operator": "||",
"left": {
"type": "ParenthesisExpression",
"span": {
"start": 55,
"end": 63,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 56,
"end": 62,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 56,
"end": 57,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 60,
"end": 62,
"ctxt": 0
},
"value": "",
"raw": "\"\""
}
}
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 67,
"end": 74,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 68,
"end": 73,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 68,
"end": 69,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 72,
"end": 73,
"ctxt": 0
},
"value": 0.0,
"raw": "0"
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 76,
"end": 78,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 76,
"end": 77,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 99,
"end": 106,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 99,
"end": 105,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 99,
"end": 100,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 103,
"end": 105,
"ctxt": 0
},
"value": "",
"raw": "\"\""
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 107,
"end": 123,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 107,
"end": 122,
"ctxt": 0
},
"operator": "||",
"left": {
"type": "Identifier",
"span": {
"start": 107,
"end": 111,
"ctxt": 0
},
"value": "cond",
"optional": false
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 115,
"end": 122,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 116,
"end": 121,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 116,
"end": 117,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 120,
"end": 121,
"ctxt": 0
},
"value": 0.0,
"raw": "0"
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 124,
"end": 126,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 124,
"end": 125,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
{
"type": "ExportDeclaration",
"span": {
"start": 147,
"end": 196,
"ctxt": 0
},
"declaration": {
"type": "TsInterfaceDeclaration",
"span": {
"start": 154,
"end": 196,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 164,
"end": 172,
"ctxt": 0
},
"value": "NodeList",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 173,
"end": 196,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 179,
"end": 194,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 179,
"end": 185,
"ctxt": 0
},
"value": "length",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 185,
"end": 193,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 187,
"end": 193,
"ctxt": 0
},
"kind": "number"
}
},
"typeParams": null
}
]
}
}
},
{
"type": "ExportDeclaration",
"span": {
"start": 198,
"end": 253,
"ctxt": 0
},
"declaration": {
"type": "TsInterfaceDeclaration",
"span": {
"start": 205,
"end": 253,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 215,
"end": 229,
"ctxt": 0
},
"value": "HTMLCollection",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 230,
"end": 253,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 236,
"end": 251,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 236,
"end": 242,
"ctxt": 0
},
"value": "length",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 242,
"end": 250,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 244,
"end": 250,
"ctxt": 0
},
"kind": "number"
}
},
"typeParams": null
}
]
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 272,
"end": 282,
"ctxt": 0
},
"value": "isNodeList",
"optional": false
},
"declare": true,
"params": [
{
"type": "Parameter",
"span": {
"start": 283,
"end": 297,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 283,
"end": 297,
"ctxt": 0
},
"value": "sourceObj",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 292,
"end": 297,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 294,
"end": 297,
"ctxt": 0
},
"kind": "any"
}
}
}
}
],
"decorators": [],
"span": {
"start": 255,
"end": 322,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 298,
"end": 321,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypePredicate",
"span": {
"start": 300,
"end": 321,
"ctxt": 0
},
"asserts": false,
"paramName": {
"type": "Identifier",
"span": {
"start": 300,
"end": 309,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 313,
"end": 321,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 313,
"end": 321,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 313,
"end": 321,
"ctxt": 0
},
"value": "NodeList",
"optional": false
},
"typeParams": null
}
}
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 340,
"end": 356,
"ctxt": 0
},
"value": "isHTMLCollection",
"optional": false
},
"declare": true,
"params": [
{
"type": "Parameter",
"span": {
"start": 357,
"end": 371,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 357,
"end": 371,
"ctxt": 0
},
"value": "sourceObj",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 366,
"end": 371,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 368,
"end": 371,
"ctxt": 0
},
"kind": "any"
}
}
}
}
],
"decorators": [],
"span": {
"start": 323,
"end": 402,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 372,
"end": 401,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypePredicate",
"span": {
"start": 374,
"end": 401,
"ctxt": 0
},
"asserts": false,
"paramName": {
"type": "Identifier",
"span": {
"start": 374,
"end": 383,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 387,
"end": 401,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 387,
"end": 401,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 387,
"end": 401,
"ctxt": 0
},
"value": "HTMLCollection",
"optional": false
},
"typeParams": null
}
}
}
}
},
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 404,
"end": 467,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 409,
"end": 424,
"ctxt": 0
},
"value": "EventTargetLike",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 427,
"end": 466,
"ctxt": 0
},
"types": [
{
"type": "TsTypeLiteral",
"span": {
"start": 427,
"end": 438,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 428,
"end": 437,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 428,
"end": 429,
"ctxt": 0
},
"value": "a",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 429,
"end": 437,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 431,
"end": 437,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
},
{
"type": "TsTypeReference",
"span": {
"start": 441,
"end": 455,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 441,
"end": 455,
"ctxt": 0
},
"value": "HTMLCollection",
"optional": false
},
"typeParams": null
},
{
"type": "TsTypeReference",
"span": {
"start": 458,
"end": 466,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 458,
"end": 466,
"ctxt": 0
},
"value": "NodeList",
"optional": false
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 469,
"end": 517,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 473,
"end": 516,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 473,
"end": 482,
"ctxt": 0
},
"value": "sourceObj",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 482,
"end": 499,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 484,
"end": 499,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 484,
"end": 499,
"ctxt": 0
},
"value": "EventTargetLike",
"optional": false
},
"typeParams": null
}
}
},
"init": {
"type": "TsTypeAssertion",
"span": {
"start": 502,
"end": 516,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 507,
"end": 516,
"ctxt": 0
},
"value": "undefined",
"optional": false
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 503,
"end": 506,
"ctxt": 0
},
"kind": "any"
}
},
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 518,
"end": 570,
"ctxt": 0
},
"test": {
"type": "CallExpression",
"span": {
"start": 522,
"end": 543,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 522,
"end": 532,
"ctxt": 0
},
"value": "isNodeList",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 533,
"end": 542,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
}
}
],
"typeArguments": null
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 545,
"end": 570,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 551,
"end": 568,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 551,
"end": 567,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 551,
"end": 560,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 561,
"end": 567,
"ctxt": 0
},
"value": "length",
"optional": false
}
}
}
]
},
"alternate": null
},
{
"type": "IfStatement",
"span": {
"start": 572,
"end": 630,
"ctxt": 0
},
"test": {
"type": "CallExpression",
"span": {
"start": 576,
"end": 603,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 576,
"end": 592,
"ctxt": 0
},
"value": "isHTMLCollection",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 593,
"end": 602,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
}
}
],
"typeArguments": null
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 605,
"end": 630,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 611,
"end": 628,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 611,
"end": 627,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 611,
"end": 620,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 621,
"end": 627,
"ctxt": 0
},
"value": "length",
"optional": false
}
}
}
]
},
"alternate": null
},
{
"type": "IfStatement",
"span": {
"start": 632,
"end": 715,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 636,
"end": 688,
"ctxt": 0
},
"operator": "||",
"left": {
"type": "CallExpression",
"span": {
"start": 636,
"end": 657,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 636,
"end": 646,
"ctxt": 0
},
"value": "isNodeList",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 647,
"end": 656,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
}
}
],
"typeArguments": null
},
"right": {
"type": "CallExpression",
"span": {
"start": 661,
"end": 688,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 661,
"end": 677,
"ctxt": 0
},
"value": "isHTMLCollection",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 678,
"end": 687,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
}
}
],
"typeArguments": null
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 690,
"end": 715,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 696,
"end": 713,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 696,
"end": 712,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 696,
"end": 705,
"ctxt": 0
},
"value": "sourceObj",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 706,
"end": 712,
"ctxt": 0
},
"value": "length",
"optional": false
}
}
}
]
},
"alternate": null
}
],
"interpreter": null
}