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

983 lines
24 KiB
JSON

{
"type": "Script",
"span": {
"start": 1,
"end": 351,
"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": 24,
"ctxt": 0
},
"kind": "boolean"
},
{
"type": "TsKeywordType",
"span": {
"start": 27,
"end": 33,
"ctxt": 0
},
"kind": "number"
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 35,
"end": 48,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 39,
"end": 47,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 39,
"end": 42,
"ctxt": 0
},
"value": "obj",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 42,
"end": 47,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 44,
"end": 47,
"ctxt": 0
},
"kind": "any"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 50,
"end": 57,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 50,
"end": 56,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 50,
"end": 51,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 54,
"end": 56,
"ctxt": 0
},
"value": "",
"raw": "\"\""
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 58,
"end": 71,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 58,
"end": 70,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 58,
"end": 59,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "MemberExpression",
"span": {
"start": 62,
"end": 70,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 62,
"end": 63,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 64,
"end": 70,
"ctxt": 0
},
"value": "length",
"optional": false
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 72,
"end": 74,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 72,
"end": 73,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 86,
"end": 95,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 86,
"end": 94,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 86,
"end": 87,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BooleanLiteral",
"span": {
"start": 90,
"end": 94,
"ctxt": 0
},
"value": true
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 96,
"end": 131,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 96,
"end": 130,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 96,
"end": 113,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 96,
"end": 109,
"ctxt": 0
},
"expression": {
"type": "SequenceExpression",
"span": {
"start": 97,
"end": 108,
"ctxt": 0
},
"expressions": [
{
"type": "AssignmentExpression",
"span": {
"start": 97,
"end": 103,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 97,
"end": 98,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 101,
"end": 103,
"ctxt": 0
},
"value": "",
"raw": "\"\""
}
},
{
"type": "Identifier",
"span": {
"start": 105,
"end": 108,
"ctxt": 0
},
"value": "obj",
"optional": false
}
]
}
},
"property": {
"type": "Identifier",
"span": {
"start": 110,
"end": 113,
"ctxt": 0
},
"value": "foo",
"optional": false
}
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 116,
"end": 130,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 117,
"end": 129,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 117,
"end": 118,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "MemberExpression",
"span": {
"start": 121,
"end": 129,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 121,
"end": 122,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 123,
"end": 129,
"ctxt": 0
},
"value": "length",
"optional": false
}
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 132,
"end": 134,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 132,
"end": 133,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 202,
"end": 264,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 207,
"end": 208,
"ctxt": 0
},
"value": "D",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 211,
"end": 263,
"ctxt": 0
},
"types": [
{
"type": "TsTypeLiteral",
"span": {
"start": 211,
"end": 235,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 213,
"end": 224,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 213,
"end": 217,
"ctxt": 0
},
"value": "done",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 217,
"end": 223,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 219,
"end": 223,
"ctxt": 0
},
"literal": {
"type": "BooleanLiteral",
"span": {
"start": 219,
"end": 223,
"ctxt": 0
},
"value": true
}
}
},
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 225,
"end": 233,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 225,
"end": 230,
"ctxt": 0
},
"value": "value",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 230,
"end": 233,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 232,
"end": 233,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 232,
"end": 233,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
}
},
"typeParams": null
}
]
},
{
"type": "TsTypeLiteral",
"span": {
"start": 238,
"end": 263,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 240,
"end": 252,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 240,
"end": 244,
"ctxt": 0
},
"value": "done",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 244,
"end": 251,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 246,
"end": 251,
"ctxt": 0
},
"literal": {
"type": "BooleanLiteral",
"span": {
"start": 246,
"end": 251,
"ctxt": 0
},
"value": false
}
}
},
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 253,
"end": 261,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 253,
"end": 258,
"ctxt": 0
},
"value": "value",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 258,
"end": 261,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 260,
"end": 261,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 260,
"end": 261,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
}
}
},
"typeParams": null
}
]
}
]
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 282,
"end": 284,
"ctxt": 0
},
"value": "fn",
"optional": false
},
"declare": true,
"params": [],
"decorators": [],
"span": {
"start": 265,
"end": 290,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 286,
"end": 289,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 288,
"end": 289,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 288,
"end": 289,
"ctxt": 0
},
"value": "D",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 291,
"end": 300,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 295,
"end": 299,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 295,
"end": 296,
"ctxt": 0
},
"value": "o",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 296,
"end": 299,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 298,
"end": 299,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 298,
"end": 299,
"ctxt": 0
},
"value": "D",
"optional": false
},
"typeParams": null
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 301,
"end": 351,
"ctxt": 0
},
"test": {
"type": "MemberExpression",
"span": {
"start": 305,
"end": 320,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 305,
"end": 315,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 306,
"end": 314,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 306,
"end": 307,
"ctxt": 0
},
"value": "o",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "CallExpression",
"span": {
"start": 310,
"end": 314,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 310,
"end": 312,
"ctxt": 0
},
"value": "fn",
"optional": false
},
"arguments": [],
"typeArguments": null
}
}
},
"property": {
"type": "Identifier",
"span": {
"start": 316,
"end": 320,
"ctxt": 0
},
"value": "done",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 322,
"end": 351,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 328,
"end": 349,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 334,
"end": 348,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 334,
"end": 335,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 335,
"end": 338,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 337,
"end": 338,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 337,
"end": 338,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
}
}
},
"init": {
"type": "MemberExpression",
"span": {
"start": 341,
"end": 348,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 341,
"end": 342,
"ctxt": 0
},
"value": "o",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 343,
"end": 348,
"ctxt": 0
},
"value": "value",
"optional": false
}
},
"definite": false
}
]
}
]
},
"alternate": null
}
],
"interpreter": null
}