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

1229 lines
35 KiB
JSON

{
"type": "Script",
"span": {
"start": 1,
"end": 754,
"ctxt": 0
},
"body": [
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 18,
"end": 35,
"ctxt": 0
},
"value": "getStringOrNumber",
"optional": false
},
"declare": true,
"params": [],
"decorators": [],
"span": {
"start": 1,
"end": 55,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 37,
"end": 54,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 39,
"end": 54,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 39,
"end": 45,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 48,
"end": 54,
"ctxt": 0
},
"kind": "number"
}
]
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 66,
"end": 68,
"ctxt": 0
},
"value": "f1",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 57,
"end": 182,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 71,
"end": 182,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 77,
"end": 107,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 83,
"end": 106,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 83,
"end": 84,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 87,
"end": 106,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 87,
"end": 104,
"ctxt": 0
},
"value": "getStringOrNumber",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 112,
"end": 180,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 116,
"end": 137,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "UnaryExpression",
"span": {
"start": 116,
"end": 124,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 123,
"end": 124,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 129,
"end": 137,
"ctxt": 0
},
"value": "string",
"raw": "\"string\""
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 139,
"end": 180,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 149,
"end": 174,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 155,
"end": 173,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 155,
"end": 156,
"ctxt": 0
},
"value": "f",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ArrowFunctionExpression",
"span": {
"start": 159,
"end": 173,
"ctxt": 0
},
"params": [],
"body": {
"type": "MemberExpression",
"span": {
"start": 165,
"end": 173,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 165,
"end": 166,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 167,
"end": 173,
"ctxt": 0
},
"value": "length",
"optional": false
}
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
},
"definite": false
}
]
}
]
},
"alternate": null
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 193,
"end": 195,
"ctxt": 0
},
"value": "f2",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 184,
"end": 321,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 198,
"end": 321,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 204,
"end": 234,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 210,
"end": 233,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 210,
"end": 211,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 214,
"end": 233,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 214,
"end": 231,
"ctxt": 0
},
"value": "getStringOrNumber",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 239,
"end": 289,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 243,
"end": 264,
"ctxt": 0
},
"operator": "!==",
"left": {
"type": "UnaryExpression",
"span": {
"start": 243,
"end": 251,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 250,
"end": 251,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 256,
"end": 264,
"ctxt": 0
},
"value": "string",
"raw": "\"string\""
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 266,
"end": 289,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 276,
"end": 283,
"ctxt": 0
},
"argument": null
}
]
},
"alternate": null
},
{
"type": "VariableDeclaration",
"span": {
"start": 294,
"end": 319,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 300,
"end": 318,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 300,
"end": 301,
"ctxt": 0
},
"value": "f",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ArrowFunctionExpression",
"span": {
"start": 304,
"end": 318,
"ctxt": 0
},
"params": [],
"body": {
"type": "MemberExpression",
"span": {
"start": 310,
"end": 318,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 310,
"end": 311,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 312,
"end": 318,
"ctxt": 0
},
"value": "length",
"optional": false
}
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
},
"definite": false
}
]
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 332,
"end": 334,
"ctxt": 0
},
"value": "f3",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 323,
"end": 465,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 337,
"end": 465,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 343,
"end": 373,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 349,
"end": 372,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 349,
"end": 350,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 353,
"end": 372,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 353,
"end": 370,
"ctxt": 0
},
"value": "getStringOrNumber",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 378,
"end": 463,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 382,
"end": 403,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "UnaryExpression",
"span": {
"start": 382,
"end": 390,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 389,
"end": 390,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 395,
"end": 403,
"ctxt": 0
},
"value": "string",
"raw": "\"string\""
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 405,
"end": 463,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 415,
"end": 457,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 421,
"end": 456,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 421,
"end": 422,
"ctxt": 0
},
"value": "f",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "FunctionExpression",
"identifier": null,
"params": [],
"decorators": [],
"span": {
"start": 425,
"end": 456,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 436,
"end": 456,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 438,
"end": 454,
"ctxt": 0
},
"argument": {
"type": "MemberExpression",
"span": {
"start": 445,
"end": 453,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 445,
"end": 446,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 447,
"end": 453,
"ctxt": 0
},
"value": "length",
"optional": false
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"definite": false
}
]
}
]
},
"alternate": null
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 476,
"end": 478,
"ctxt": 0
},
"value": "f4",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 467,
"end": 621,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 481,
"end": 621,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 487,
"end": 517,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 493,
"end": 516,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 493,
"end": 494,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 497,
"end": 516,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 497,
"end": 514,
"ctxt": 0
},
"value": "getStringOrNumber",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 522,
"end": 572,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 526,
"end": 547,
"ctxt": 0
},
"operator": "!==",
"left": {
"type": "UnaryExpression",
"span": {
"start": 526,
"end": 534,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 533,
"end": 534,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 539,
"end": 547,
"ctxt": 0
},
"value": "string",
"raw": "\"string\""
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 549,
"end": 572,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 559,
"end": 566,
"ctxt": 0
},
"argument": null
}
]
},
"alternate": null
},
{
"type": "VariableDeclaration",
"span": {
"start": 577,
"end": 619,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 583,
"end": 618,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 583,
"end": 584,
"ctxt": 0
},
"value": "f",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "FunctionExpression",
"identifier": null,
"params": [],
"decorators": [],
"span": {
"start": 587,
"end": 618,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 598,
"end": 618,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 600,
"end": 616,
"ctxt": 0
},
"argument": {
"type": "MemberExpression",
"span": {
"start": 607,
"end": 615,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 607,
"end": 608,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 609,
"end": 615,
"ctxt": 0
},
"value": "length",
"optional": false
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"definite": false
}
]
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 632,
"end": 634,
"ctxt": 0
},
"value": "f5",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 623,
"end": 754,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 637,
"end": 754,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 643,
"end": 673,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 649,
"end": 672,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 649,
"end": 650,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 653,
"end": 672,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 653,
"end": 670,
"ctxt": 0
},
"value": "getStringOrNumber",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 678,
"end": 752,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 682,
"end": 703,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "UnaryExpression",
"span": {
"start": 682,
"end": 690,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 689,
"end": 690,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 695,
"end": 703,
"ctxt": 0
},
"value": "string",
"raw": "\"string\""
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 705,
"end": 752,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 715,
"end": 746,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 721,
"end": 745,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 721,
"end": 722,
"ctxt": 0
},
"value": "f",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ArrowFunctionExpression",
"span": {
"start": 725,
"end": 745,
"ctxt": 0
},
"params": [],
"body": {
"type": "ArrowFunctionExpression",
"span": {
"start": 731,
"end": 745,
"ctxt": 0
},
"params": [],
"body": {
"type": "MemberExpression",
"span": {
"start": 737,
"end": 745,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 737,
"end": 738,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 739,
"end": 745,
"ctxt": 0
},
"value": "length",
"optional": false
}
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
},
"definite": false
}
]
}
]
},
"alternate": null
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
],
"interpreter": null
}