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

992 lines
27 KiB
JSON

{
"type": "Script",
"span": {
"start": 60,
"end": 622,
"ctxt": 0
},
"body": [
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 69,
"end": 71,
"ctxt": 0
},
"value": "f1",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 75,
"end": 138,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "AssignmentPattern",
"span": {
"start": 75,
"end": 138,
"ctxt": 0
},
"left": {
"type": "Identifier",
"span": {
"start": 75,
"end": 92,
"ctxt": 0
},
"value": "required",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 83,
"end": 92,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 85,
"end": 92,
"ctxt": 0
},
"kind": "unknown"
}
}
},
"right": {
"type": "CallExpression",
"span": {
"start": 95,
"end": 138,
"ctxt": 0
},
"callee": {
"type": "ParenthesisExpression",
"span": {
"start": 95,
"end": 136,
"ctxt": 0
},
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 96,
"end": 135,
"ctxt": 0
},
"params": [],
"body": {
"type": "BlockStatement",
"span": {
"start": 102,
"end": 135,
"ctxt": 0
},
"stmts": [
{
"type": "ThrowStatement",
"span": {
"start": 108,
"end": 131,
"ctxt": 0
},
"argument": {
"type": "NewExpression",
"span": {
"start": 114,
"end": 130,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 118,
"end": 123,
"ctxt": 0
},
"value": "Error",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "StringLiteral",
"span": {
"start": 124,
"end": 129,
"ctxt": 0
},
"value": "bad",
"raw": "\"bad\""
}
}
],
"typeArguments": null
}
}
]
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
},
"arguments": [],
"typeArguments": null
},
"typeAnnotation": null
}
}
],
"decorators": [],
"span": {
"start": 60,
"end": 216,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 141,
"end": 216,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 145,
"end": 163,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 145,
"end": 162,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 145,
"end": 156,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 145,
"end": 152,
"ctxt": 0
},
"value": "console",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 153,
"end": 156,
"ctxt": 0
},
"value": "log",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "StringLiteral",
"span": {
"start": 157,
"end": 161,
"ctxt": 0
},
"value": "ok",
"raw": "\"ok\""
}
}
],
"typeArguments": null
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 227,
"end": 229,
"ctxt": 0
},
"value": "f2",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 233,
"end": 263,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 233,
"end": 263,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 234,
"end": 263,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 236,
"end": 263,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 236,
"end": 242,
"ctxt": 0
},
"kind": "number"
},
{
"type": "TsKeywordType",
"span": {
"start": 245,
"end": 251,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 254,
"end": 263,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
}
},
{
"type": "Parameter",
"span": {
"start": 267,
"end": 313,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "AssignmentPattern",
"span": {
"start": 267,
"end": 313,
"ctxt": 0
},
"left": {
"type": "Identifier",
"span": {
"start": 267,
"end": 284,
"ctxt": 0
},
"value": "required",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 275,
"end": 284,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 277,
"end": 284,
"ctxt": 0
},
"kind": "unknown"
}
}
},
"right": {
"type": "CallExpression",
"span": {
"start": 287,
"end": 313,
"ctxt": 0
},
"callee": {
"type": "ParenthesisExpression",
"span": {
"start": 287,
"end": 311,
"ctxt": 0
},
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 288,
"end": 310,
"ctxt": 0
},
"params": [],
"body": {
"type": "BlockStatement",
"span": {
"start": 294,
"end": 310,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 300,
"end": 306,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 300,
"end": 305,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 300,
"end": 301,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 304,
"end": 305,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
}
}
]
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
},
"arguments": [],
"typeArguments": null
},
"typeAnnotation": null
}
}
],
"decorators": [],
"span": {
"start": 218,
"end": 365,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 316,
"end": 365,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 320,
"end": 322,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 320,
"end": 321,
"ctxt": 0
},
"value": "a",
"optional": false
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 376,
"end": 378,
"ctxt": 0
},
"value": "f3",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 382,
"end": 416,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "AssignmentPattern",
"span": {
"start": 382,
"end": 416,
"ctxt": 0
},
"left": {
"type": "Identifier",
"span": {
"start": 382,
"end": 412,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 383,
"end": 412,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 385,
"end": 412,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 385,
"end": 391,
"ctxt": 0
},
"kind": "number"
},
{
"type": "TsKeywordType",
"span": {
"start": 394,
"end": 400,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 403,
"end": 412,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 415,
"end": 416,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"typeAnnotation": null
}
},
{
"type": "Parameter",
"span": {
"start": 420,
"end": 467,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "AssignmentPattern",
"span": {
"start": 420,
"end": 467,
"ctxt": 0
},
"left": {
"type": "Identifier",
"span": {
"start": 420,
"end": 437,
"ctxt": 0
},
"value": "required",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 428,
"end": 437,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 430,
"end": 437,
"ctxt": 0
},
"kind": "unknown"
}
}
},
"right": {
"type": "CallExpression",
"span": {
"start": 440,
"end": 467,
"ctxt": 0
},
"callee": {
"type": "ParenthesisExpression",
"span": {
"start": 440,
"end": 465,
"ctxt": 0
},
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 441,
"end": 464,
"ctxt": 0
},
"params": [],
"body": {
"type": "BlockStatement",
"span": {
"start": 447,
"end": 464,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 453,
"end": 460,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 453,
"end": 459,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 453,
"end": 454,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 457,
"end": 459,
"ctxt": 0
},
"value": "",
"raw": "\"\""
}
}
}
]
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
},
"arguments": [],
"typeArguments": null
},
"typeAnnotation": null
}
}
],
"decorators": [],
"span": {
"start": 367,
"end": 507,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 470,
"end": 507,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 474,
"end": 476,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 474,
"end": 475,
"ctxt": 0
},
"value": "a",
"optional": false
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 518,
"end": 520,
"ctxt": 0
},
"value": "f4",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 524,
"end": 558,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "AssignmentPattern",
"span": {
"start": 524,
"end": 558,
"ctxt": 0
},
"left": {
"type": "Identifier",
"span": {
"start": 524,
"end": 554,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 525,
"end": 554,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 527,
"end": 554,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 527,
"end": 533,
"ctxt": 0
},
"kind": "number"
},
{
"type": "TsKeywordType",
"span": {
"start": 536,
"end": 542,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 545,
"end": 554,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 557,
"end": 558,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"typeAnnotation": null
}
},
{
"type": "Parameter",
"span": {
"start": 562,
"end": 591,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "AssignmentPattern",
"span": {
"start": 562,
"end": 591,
"ctxt": 0
},
"left": {
"type": "ObjectPattern",
"span": {
"start": 562,
"end": 579,
"ctxt": 0
},
"properties": [
{
"type": "KeyValuePatternProperty",
"key": {
"type": "Computed",
"span": {
"start": 564,
"end": 574,
"ctxt": 0
},
"expression": {
"type": "ParenthesisExpression",
"span": {
"start": 565,
"end": 573,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 566,
"end": 572,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 566,
"end": 567,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 570,
"end": 572,
"ctxt": 0
},
"value": "",
"raw": "\"\""
}
}
}
},
"value": {
"type": "Identifier",
"span": {
"start": 576,
"end": 577,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": null
}
}
],
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "TsAsExpression",
"span": {
"start": 582,
"end": 591,
"ctxt": 0
},
"expression": {
"type": "ObjectExpression",
"span": {
"start": 582,
"end": 584,
"ctxt": 0
},
"properties": []
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 588,
"end": 591,
"ctxt": 0
},
"kind": "any"
}
},
"typeAnnotation": null
}
}
],
"decorators": [],
"span": {
"start": 509,
"end": 622,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 594,
"end": 622,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 598,
"end": 600,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 598,
"end": 599,
"ctxt": 0
},
"value": "a",
"optional": false
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
],
"interpreter": null
}