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

988 lines
24 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
"start": 0,
"end": 350,
"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": 23,
"ctxt": 0
},
"kind": "boolean"
},
{
"type": "TsKeywordType",
"span": {
"start": 26,
"end": 32,
"ctxt": 0
},
"kind": "number"
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 34,
"end": 47,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 38,
"end": 46,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 38,
"end": 41,
"ctxt": 0
},
"value": "obj",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 41,
"end": 46,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 43,
"end": 46,
"ctxt": 0
},
"kind": "any"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 49,
"end": 56,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 49,
"end": 55,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 49,
"end": 50,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 53,
"end": 55,
"ctxt": 0
},
"value": "",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 57,
"end": 70,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 57,
"end": 69,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 57,
"end": 58,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "MemberExpression",
"span": {
"start": 61,
"end": 69,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 61,
"end": 62,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 63,
"end": 69,
"ctxt": 0
},
"value": "length",
"optional": false
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 71,
"end": 73,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 71,
"end": 72,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 85,
"end": 94,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 85,
"end": 93,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 85,
"end": 86,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BooleanLiteral",
"span": {
"start": 89,
"end": 93,
"ctxt": 0
},
"value": true
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 95,
"end": 130,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 95,
"end": 129,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 95,
"end": 112,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 95,
"end": 108,
"ctxt": 0
},
"expression": {
"type": "SequenceExpression",
"span": {
"start": 96,
"end": 107,
"ctxt": 0
},
"expressions": [
{
"type": "AssignmentExpression",
"span": {
"start": 96,
"end": 102,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 96,
"end": 97,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 100,
"end": 102,
"ctxt": 0
},
"value": "",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
{
"type": "Identifier",
"span": {
"start": 104,
"end": 107,
"ctxt": 0
},
"value": "obj",
"optional": false
}
]
}
},
"property": {
"type": "Identifier",
"span": {
"start": 109,
"end": 112,
"ctxt": 0
},
"value": "foo",
"optional": false
}
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 115,
"end": 129,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 116,
"end": 128,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 116,
"end": 117,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "MemberExpression",
"span": {
"start": 120,
"end": 128,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 120,
"end": 121,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 122,
"end": 128,
"ctxt": 0
},
"value": "length",
"optional": false
}
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 131,
"end": 133,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 131,
"end": 132,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 201,
"end": 263,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 206,
"end": 207,
"ctxt": 0
},
"value": "D",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 210,
"end": 262,
"ctxt": 0
},
"types": [
{
"type": "TsTypeLiteral",
"span": {
"start": 210,
"end": 234,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 212,
"end": 223,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 212,
"end": 216,
"ctxt": 0
},
"value": "done",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 216,
"end": 222,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 218,
"end": 222,
"ctxt": 0
},
"literal": {
"type": "BooleanLiteral",
"span": {
"start": 218,
"end": 222,
"ctxt": 0
},
"value": true
}
}
},
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 224,
"end": 232,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 224,
"end": 229,
"ctxt": 0
},
"value": "value",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 229,
"end": 232,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 231,
"end": 232,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 231,
"end": 232,
"ctxt": 0
},
"value": 1.0
}
}
},
"typeParams": null
}
]
},
{
"type": "TsTypeLiteral",
"span": {
"start": 237,
"end": 262,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 239,
"end": 251,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 239,
"end": 243,
"ctxt": 0
},
"value": "done",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 243,
"end": 250,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 245,
"end": 250,
"ctxt": 0
},
"literal": {
"type": "BooleanLiteral",
"span": {
"start": 245,
"end": 250,
"ctxt": 0
},
"value": false
}
}
},
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 252,
"end": 260,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 252,
"end": 257,
"ctxt": 0
},
"value": "value",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 257,
"end": 260,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 259,
"end": 260,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 259,
"end": 260,
"ctxt": 0
},
"value": 2.0
}
}
},
"typeParams": null
}
]
}
]
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 281,
"end": 283,
"ctxt": 0
},
"value": "fn",
"optional": false
},
"declare": true,
"params": [],
"decorators": [],
"span": {
"start": 264,
"end": 289,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 285,
"end": 288,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 287,
"end": 288,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 287,
"end": 288,
"ctxt": 0
},
"value": "D",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 290,
"end": 299,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 294,
"end": 298,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 294,
"end": 295,
"ctxt": 0
},
"value": "o",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 295,
"end": 298,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 297,
"end": 298,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 297,
"end": 298,
"ctxt": 0
},
"value": "D",
"optional": false
},
"typeParams": null
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 300,
"end": 350,
"ctxt": 0
},
"test": {
"type": "MemberExpression",
"span": {
"start": 304,
"end": 319,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 304,
"end": 314,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 305,
"end": 313,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 305,
"end": 306,
"ctxt": 0
},
"value": "o",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "CallExpression",
"span": {
"start": 309,
"end": 313,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 309,
"end": 311,
"ctxt": 0
},
"value": "fn",
"optional": false
},
"arguments": [],
"typeArguments": null
}
}
},
"property": {
"type": "Identifier",
"span": {
"start": 315,
"end": 319,
"ctxt": 0
},
"value": "done",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 321,
"end": 350,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 327,
"end": 348,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 333,
"end": 347,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 333,
"end": 334,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 334,
"end": 337,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 336,
"end": 337,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 336,
"end": 337,
"ctxt": 0
},
"value": 1.0
}
}
}
},
"init": {
"type": "MemberExpression",
"span": {
"start": 340,
"end": 347,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 340,
"end": 341,
"ctxt": 0
},
"value": "o",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 342,
"end": 347,
"ctxt": 0
},
"value": "value",
"optional": false
}
},
"definite": false
}
]
}
]
},
"alternate": null
}
],
"interpreter": null
}