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

1249 lines
35 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
"start": 0,
"end": 753,
"ctxt": 0
},
"body": [
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 17,
"end": 34,
"ctxt": 0
},
"value": "getStringOrNumber",
"optional": false
},
"declare": true,
"params": [],
"decorators": [],
"span": {
"start": 0,
"end": 54,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 36,
"end": 53,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 38,
"end": 53,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 38,
"end": 44,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 47,
"end": 53,
"ctxt": 0
},
"kind": "number"
}
]
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 65,
"end": 67,
"ctxt": 0
},
"value": "f1",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 56,
"end": 181,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 70,
"end": 181,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 76,
"end": 106,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 82,
"end": 105,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 82,
"end": 83,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 86,
"end": 105,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 86,
"end": 103,
"ctxt": 0
},
"value": "getStringOrNumber",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 111,
"end": 179,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 115,
"end": 136,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "UnaryExpression",
"span": {
"start": 115,
"end": 123,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 122,
"end": 123,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 128,
"end": 136,
"ctxt": 0
},
"value": "string",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 138,
"end": 179,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 148,
"end": 173,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 154,
"end": 172,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 154,
"end": 155,
"ctxt": 0
},
"value": "f",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ArrowFunctionExpression",
"span": {
"start": 158,
"end": 172,
"ctxt": 0
},
"params": [],
"body": {
"type": "MemberExpression",
"span": {
"start": 164,
"end": 172,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 164,
"end": 165,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 166,
"end": 172,
"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": 192,
"end": 194,
"ctxt": 0
},
"value": "f2",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 183,
"end": 320,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 197,
"end": 320,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 203,
"end": 233,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 209,
"end": 232,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 209,
"end": 210,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 213,
"end": 232,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 213,
"end": 230,
"ctxt": 0
},
"value": "getStringOrNumber",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 238,
"end": 288,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 242,
"end": 263,
"ctxt": 0
},
"operator": "!==",
"left": {
"type": "UnaryExpression",
"span": {
"start": 242,
"end": 250,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 249,
"end": 250,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 255,
"end": 263,
"ctxt": 0
},
"value": "string",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 265,
"end": 288,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 275,
"end": 282,
"ctxt": 0
},
"argument": null
}
]
},
"alternate": null
},
{
"type": "VariableDeclaration",
"span": {
"start": 293,
"end": 318,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 299,
"end": 317,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 299,
"end": 300,
"ctxt": 0
},
"value": "f",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ArrowFunctionExpression",
"span": {
"start": 303,
"end": 317,
"ctxt": 0
},
"params": [],
"body": {
"type": "MemberExpression",
"span": {
"start": 309,
"end": 317,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 309,
"end": 310,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 311,
"end": 317,
"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": 331,
"end": 333,
"ctxt": 0
},
"value": "f3",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 322,
"end": 464,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 336,
"end": 464,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 342,
"end": 372,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 348,
"end": 371,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 348,
"end": 349,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 352,
"end": 371,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 352,
"end": 369,
"ctxt": 0
},
"value": "getStringOrNumber",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 377,
"end": 462,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 381,
"end": 402,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "UnaryExpression",
"span": {
"start": 381,
"end": 389,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 388,
"end": 389,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 394,
"end": 402,
"ctxt": 0
},
"value": "string",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 404,
"end": 462,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 414,
"end": 456,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 420,
"end": 455,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 420,
"end": 421,
"ctxt": 0
},
"value": "f",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "FunctionExpression",
"identifier": null,
"params": [],
"decorators": [],
"span": {
"start": 424,
"end": 455,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 435,
"end": 455,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 437,
"end": 453,
"ctxt": 0
},
"argument": {
"type": "MemberExpression",
"span": {
"start": 444,
"end": 452,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 444,
"end": 445,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 446,
"end": 452,
"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": 475,
"end": 477,
"ctxt": 0
},
"value": "f4",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 466,
"end": 620,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 480,
"end": 620,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 486,
"end": 516,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 492,
"end": 515,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 492,
"end": 493,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 496,
"end": 515,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 496,
"end": 513,
"ctxt": 0
},
"value": "getStringOrNumber",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 521,
"end": 571,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 525,
"end": 546,
"ctxt": 0
},
"operator": "!==",
"left": {
"type": "UnaryExpression",
"span": {
"start": 525,
"end": 533,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 532,
"end": 533,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 538,
"end": 546,
"ctxt": 0
},
"value": "string",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 548,
"end": 571,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 558,
"end": 565,
"ctxt": 0
},
"argument": null
}
]
},
"alternate": null
},
{
"type": "VariableDeclaration",
"span": {
"start": 576,
"end": 618,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 582,
"end": 617,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 582,
"end": 583,
"ctxt": 0
},
"value": "f",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "FunctionExpression",
"identifier": null,
"params": [],
"decorators": [],
"span": {
"start": 586,
"end": 617,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 597,
"end": 617,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 599,
"end": 615,
"ctxt": 0
},
"argument": {
"type": "MemberExpression",
"span": {
"start": 606,
"end": 614,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 606,
"end": 607,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 608,
"end": 614,
"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": 631,
"end": 633,
"ctxt": 0
},
"value": "f5",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 622,
"end": 753,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 636,
"end": 753,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 642,
"end": 672,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 648,
"end": 671,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 648,
"end": 649,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 652,
"end": 671,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 652,
"end": 669,
"ctxt": 0
},
"value": "getStringOrNumber",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 677,
"end": 751,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 681,
"end": 702,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "UnaryExpression",
"span": {
"start": 681,
"end": 689,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 688,
"end": 689,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 694,
"end": 702,
"ctxt": 0
},
"value": "string",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 704,
"end": 751,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 714,
"end": 745,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 720,
"end": 744,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 720,
"end": 721,
"ctxt": 0
},
"value": "f",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ArrowFunctionExpression",
"span": {
"start": 724,
"end": 744,
"ctxt": 0
},
"params": [],
"body": {
"type": "ArrowFunctionExpression",
"span": {
"start": 730,
"end": 744,
"ctxt": 0
},
"params": [],
"body": {
"type": "MemberExpression",
"span": {
"start": 736,
"end": 744,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 736,
"end": 737,
"ctxt": 0
},
"value": "x",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 738,
"end": 744,
"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
}