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

1111 lines
25 KiB
JSON

{
"type": "Script",
"span": {
"start": 33,
"end": 558,
"ctxt": 0
},
"body": [
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 42,
"end": 44,
"ctxt": 0
},
"value": "fn",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 45,
"end": 46,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 45,
"end": 46,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
}
}
],
"decorators": [],
"span": {
"start": 33,
"end": 64,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 48,
"end": 64,
"ctxt": 0
},
"stmts": [
{
"type": "ThrowStatement",
"span": {
"start": 54,
"end": 62,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 60,
"end": 61,
"ctxt": 0
},
"value": "x",
"optional": false
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
{
"type": "ExpressionStatement",
"span": {
"start": 66,
"end": 91,
"ctxt": 0
},
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 66,
"end": 91,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 70,
"end": 74,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 71,
"end": 74,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 73,
"end": 74,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 73,
"end": 74,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
],
"body": {
"type": "BlockStatement",
"span": {
"start": 79,
"end": 91,
"ctxt": 0
},
"stmts": [
{
"type": "ThrowStatement",
"span": {
"start": 81,
"end": 89,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 87,
"end": 88,
"ctxt": 0
},
"value": "x",
"optional": false
}
}
]
},
"async": false,
"generator": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 66,
"end": 69,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 67,
"end": 68,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 67,
"end": 68,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
},
"returnType": null
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 93,
"end": 107,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 97,
"end": 106,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 97,
"end": 98,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 98,
"end": 106,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 100,
"end": 106,
"ctxt": 0
},
"kind": "string"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "SwitchStatement",
"span": {
"start": 108,
"end": 183,
"ctxt": 0
},
"discriminant": {
"type": "Identifier",
"span": {
"start": 116,
"end": 117,
"ctxt": 0
},
"value": "y",
"optional": false
},
"cases": [
{
"type": "SwitchCase",
"span": {
"start": 125,
"end": 151,
"ctxt": 0
},
"test": {
"type": "StringLiteral",
"span": {
"start": 130,
"end": 133,
"ctxt": 0
},
"value": "a",
"raw": "'a'"
},
"consequent": [
{
"type": "ThrowStatement",
"span": {
"start": 143,
"end": 151,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 149,
"end": 150,
"ctxt": 0
},
"value": "y",
"optional": false
}
}
]
},
{
"type": "SwitchCase",
"span": {
"start": 156,
"end": 181,
"ctxt": 0
},
"test": null,
"consequent": [
{
"type": "ThrowStatement",
"span": {
"start": 173,
"end": 181,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 179,
"end": 180,
"ctxt": 0
},
"value": "y",
"optional": false
}
}
]
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 185,
"end": 195,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 189,
"end": 194,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 189,
"end": 190,
"ctxt": 0
},
"value": "z",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "NumericLiteral",
"span": {
"start": 193,
"end": 194,
"ctxt": 0
},
"value": 0.0,
"raw": "0"
},
"definite": false
}
]
},
{
"type": "WhileStatement",
"span": {
"start": 196,
"end": 227,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 203,
"end": 209,
"ctxt": 0
},
"operator": "<",
"left": {
"type": "Identifier",
"span": {
"start": 203,
"end": 204,
"ctxt": 0
},
"value": "z",
"optional": false
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 207,
"end": 209,
"ctxt": 0
},
"value": 10.0,
"raw": "10"
}
},
"body": {
"type": "BlockStatement",
"span": {
"start": 211,
"end": 227,
"ctxt": 0
},
"stmts": [
{
"type": "ThrowStatement",
"span": {
"start": 217,
"end": 225,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 223,
"end": 224,
"ctxt": 0
},
"value": "z",
"optional": false
}
}
]
}
},
{
"type": "ForStatement",
"span": {
"start": 229,
"end": 260,
"ctxt": 0
},
"init": {
"type": "VariableDeclaration",
"span": {
"start": 234,
"end": 243,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 238,
"end": 243,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 238,
"end": 239,
"ctxt": 0
},
"value": "i",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "NumericLiteral",
"span": {
"start": 242,
"end": 243,
"ctxt": 0
},
"value": 0.0,
"raw": "0"
},
"definite": false
}
]
},
"test": null,
"update": null,
"body": {
"type": "BlockStatement",
"span": {
"start": 248,
"end": 260,
"ctxt": 0
},
"stmts": [
{
"type": "ThrowStatement",
"span": {
"start": 250,
"end": 258,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 256,
"end": 257,
"ctxt": 0
},
"value": "i",
"optional": false
}
}
]
}
},
{
"type": "ForInStatement",
"span": {
"start": 262,
"end": 296,
"ctxt": 0
},
"left": {
"type": "VariableDeclaration",
"span": {
"start": 267,
"end": 274,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 271,
"end": 274,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 271,
"end": 274,
"ctxt": 0
},
"value": "idx",
"optional": false,
"typeAnnotation": null
},
"init": null,
"definite": false
}
]
},
"right": {
"type": "ObjectExpression",
"span": {
"start": 278,
"end": 280,
"ctxt": 0
},
"properties": []
},
"body": {
"type": "BlockStatement",
"span": {
"start": 282,
"end": 296,
"ctxt": 0
},
"stmts": [
{
"type": "ThrowStatement",
"span": {
"start": 284,
"end": 294,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 290,
"end": 293,
"ctxt": 0
},
"value": "idx",
"optional": false
}
}
]
}
},
{
"type": "DoWhileStatement",
"span": {
"start": 298,
"end": 327,
"ctxt": 0
},
"test": {
"type": "BooleanLiteral",
"span": {
"start": 322,
"end": 326,
"ctxt": 0
},
"value": true
},
"body": {
"type": "BlockStatement",
"span": {
"start": 301,
"end": 316,
"ctxt": 0
},
"stmts": [
{
"type": "ThrowStatement",
"span": {
"start": 303,
"end": 314,
"ctxt": 0
},
"argument": {
"type": "NullLiteral",
"span": {
"start": 309,
"end": 313,
"ctxt": 0
}
}
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 329,
"end": 339,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 333,
"end": 338,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 333,
"end": 334,
"ctxt": 0
},
"value": "j",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "NumericLiteral",
"span": {
"start": 337,
"end": 338,
"ctxt": 0
},
"value": 0.0,
"raw": "0"
},
"definite": false
}
]
},
{
"type": "WhileStatement",
"span": {
"start": 340,
"end": 366,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 347,
"end": 352,
"ctxt": 0
},
"operator": "<",
"left": {
"type": "Identifier",
"span": {
"start": 347,
"end": 348,
"ctxt": 0
},
"value": "j",
"optional": false
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 351,
"end": 352,
"ctxt": 0
},
"value": 0.0,
"raw": "0"
}
},
"body": {
"type": "BlockStatement",
"span": {
"start": 354,
"end": 366,
"ctxt": 0
},
"stmts": [
{
"type": "ThrowStatement",
"span": {
"start": 356,
"end": 364,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 362,
"end": 363,
"ctxt": 0
},
"value": "j",
"optional": false
}
}
]
}
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 374,
"end": 375,
"ctxt": 0
},
"value": "C",
"optional": false
},
"declare": false,
"span": {
"start": 368,
"end": 495,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 385,
"end": 402,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 393,
"end": 398,
"ctxt": 0
},
"value": "value",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 398,
"end": 401,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 400,
"end": 401,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 400,
"end": 401,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
},
"isStatic": false,
"decorators": [],
"accessibility": "private",
"isAbstract": false,
"isOptional": false,
"isOverride": false,
"readonly": false,
"declare": false,
"definite": false
},
{
"type": "ClassMethod",
"span": {
"start": 407,
"end": 446,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 407,
"end": 410,
"ctxt": 0
},
"value": "biz",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 407,
"end": 446,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 413,
"end": 446,
"ctxt": 0
},
"stmts": [
{
"type": "ThrowStatement",
"span": {
"start": 423,
"end": 440,
"ctxt": 0
},
"argument": {
"type": "MemberExpression",
"span": {
"start": 429,
"end": 439,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 429,
"end": 433,
"ctxt": 0
}
},
"property": {
"type": "Identifier",
"span": {
"start": 434,
"end": 439,
"ctxt": 0
},
"value": "value",
"optional": false
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "Constructor",
"span": {
"start": 452,
"end": 493,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 452,
"end": 463,
"ctxt": 0
},
"value": "constructor",
"optional": false
},
"params": [],
"body": {
"type": "BlockStatement",
"span": {
"start": 466,
"end": 493,
"ctxt": 0
},
"stmts": [
{
"type": "ThrowStatement",
"span": {
"start": 476,
"end": 487,
"ctxt": 0
},
"argument": {
"type": "ThisExpression",
"span": {
"start": 482,
"end": 486,
"ctxt": 0
}
}
}
]
},
"accessibility": null,
"isOptional": false
}
],
"superClass": null,
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 375,
"end": 378,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 376,
"end": 377,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 376,
"end": 377,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
},
"superTypeParams": null,
"implements": []
},
{
"type": "VariableDeclaration",
"span": {
"start": 497,
"end": 558,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 501,
"end": 558,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 501,
"end": 503,
"ctxt": 0
},
"value": "aa",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ObjectExpression",
"span": {
"start": 506,
"end": 558,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 512,
"end": 514,
"ctxt": 0
},
"value": "id",
"optional": false
},
"value": {
"type": "NumericLiteral",
"span": {
"start": 515,
"end": 517,
"ctxt": 0
},
"value": 12.0,
"raw": "12"
}
},
{
"type": "MethodProperty",
"key": {
"type": "Identifier",
"span": {
"start": 523,
"end": 526,
"ctxt": 0
},
"value": "biz",
"optional": false
},
"params": [],
"decorators": [],
"span": {
"start": 523,
"end": 556,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 529,
"end": 556,
"ctxt": 0
},
"stmts": [
{
"type": "ThrowStatement",
"span": {
"start": 539,
"end": 550,
"ctxt": 0
},
"argument": {
"type": "ThisExpression",
"span": {
"start": 545,
"end": 549,
"ctxt": 0
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
]
},
"definite": false
}
]
}
],
"interpreter": null
}