swc/crates/swc_ecma_parser/tests/tsc/optionalChainingInParameterBindingPattern.2.json
Donny/강동윤 aa83584634
refactor(es/ast): Reimplement optional chaining (#7441)
**Related issue:**

 - Closes #7003.
 - Closes #7156.
2023-06-12 06:47:40 +00:00

563 lines
16 KiB
JSON

{
"type": "Script",
"span": {
"start": 133,
"end": 287,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 133,
"end": 186,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 139,
"end": 185,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 139,
"end": 140,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ArrowFunctionExpression",
"span": {
"start": 143,
"end": 185,
"ctxt": 0
},
"params": [],
"body": {
"type": "Identifier",
"span": {
"start": 176,
"end": 185,
"ctxt": 0
},
"value": "undefined",
"optional": false
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 145,
"end": 172,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 147,
"end": 172,
"ctxt": 0
},
"types": [
{
"type": "TsTypeLiteral",
"span": {
"start": 147,
"end": 160,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 149,
"end": 158,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 149,
"end": 150,
"ctxt": 0
},
"value": "d",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 150,
"end": 158,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 152,
"end": 158,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
},
{
"type": "TsKeywordType",
"span": {
"start": 163,
"end": 172,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
},
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 187,
"end": 228,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 187,
"end": 227,
"ctxt": 0
},
"callee": {
"type": "ParenthesisExpression",
"span": {
"start": 187,
"end": 225,
"ctxt": 0
},
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 188,
"end": 224,
"ctxt": 0
},
"params": [
{
"type": "ObjectPattern",
"span": {
"start": 189,
"end": 209,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "Computed",
"span": {
"start": 191,
"end": 199,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 192,
"end": 198,
"ctxt": 0
},
"optional": true,
"base": {
"type": "MemberExpression",
"span": {
"start": 192,
"end": 198,
"ctxt": 0
},
"object": {
"type": "CallExpression",
"span": {
"start": 192,
"end": 195,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 192,
"end": 193,
"ctxt": 0
},
"value": "a",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"property": {
"type": "Identifier",
"span": {
"start": 197,
"end": 198,
"ctxt": 0
},
"value": "d",
"optional": false
}
}
}
},
"value": {
"type": "AssignmentPattern",
"span": {
"start": 201,
"end": 207,
"ctxt": 0
},
"left": {
"type": "Identifier",
"span": {
"start": 201,
"end": 202,
"ctxt": 0
},
"value": "c",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 205,
"end": 207,
"ctxt": 0
},
"value": "",
"raw": "\"\""
},
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
}
],
"body": {
"type": "BlockStatement",
"span": {
"start": 214,
"end": 224,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 216,
"end": 222,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 220,
"end": 221,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 220,
"end": 221,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": null
},
"init": null,
"definite": false
}
]
}
]
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
},
"arguments": [],
"typeArguments": null
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 230,
"end": 243,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 236,
"end": 242,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 236,
"end": 237,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "StringLiteral",
"span": {
"start": 240,
"end": 242,
"ctxt": 0
},
"value": "",
"raw": "\"\""
},
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 244,
"end": 287,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 244,
"end": 286,
"ctxt": 0
},
"callee": {
"type": "ParenthesisExpression",
"span": {
"start": 244,
"end": 284,
"ctxt": 0
},
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 245,
"end": 283,
"ctxt": 0
},
"params": [
{
"type": "ObjectPattern",
"span": {
"start": 246,
"end": 261,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "Computed",
"span": {
"start": 248,
"end": 256,
"ctxt": 0
},
"expression": {
"type": "OptionalChainingExpression",
"span": {
"start": 249,
"end": 255,
"ctxt": 0
},
"optional": true,
"base": {
"type": "MemberExpression",
"span": {
"start": 249,
"end": 255,
"ctxt": 0
},
"object": {
"type": "CallExpression",
"span": {
"start": 249,
"end": 252,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 249,
"end": 250,
"ctxt": 0
},
"value": "a",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"property": {
"type": "Identifier",
"span": {
"start": 254,
"end": 255,
"ctxt": 0
},
"value": "d",
"optional": false
}
}
}
},
"value": {
"type": "Identifier",
"span": {
"start": 258,
"end": 259,
"ctxt": 0
},
"value": "c",
"optional": false,
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
},
{
"type": "AssignmentPattern",
"span": {
"start": 263,
"end": 268,
"ctxt": 0
},
"left": {
"type": "Identifier",
"span": {
"start": 263,
"end": 264,
"ctxt": 0
},
"value": "d",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 267,
"end": 268,
"ctxt": 0
},
"value": "x",
"optional": false
},
"typeAnnotation": null
}
],
"body": {
"type": "BlockStatement",
"span": {
"start": 273,
"end": 283,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 275,
"end": 281,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 279,
"end": 280,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 279,
"end": 280,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": null,
"definite": false
}
]
}
]
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
},
"arguments": [],
"typeArguments": null
}
}
],
"interpreter": null
}