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

662 lines
16 KiB
JSON

{
"type": "Script",
"span": {
"start": 15,
"end": 252,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 15,
"end": 33,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 19,
"end": 33,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 19,
"end": 21,
"ctxt": 0
},
"value": "f1",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ArrowFunctionExpression",
"span": {
"start": 24,
"end": 33,
"ctxt": 0
},
"params": [],
"body": {
"type": "BlockStatement",
"span": {
"start": 30,
"end": 33,
"ctxt": 0
},
"stmts": []
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 34,
"end": 72,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 38,
"end": 72,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 38,
"end": 40,
"ctxt": 0
},
"value": "f2",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ArrowFunctionExpression",
"span": {
"start": 43,
"end": 72,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 44,
"end": 53,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 45,
"end": 53,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 47,
"end": 53,
"ctxt": 0
},
"kind": "string"
}
}
},
{
"type": "Identifier",
"span": {
"start": 55,
"end": 64,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 56,
"end": 64,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 58,
"end": 64,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"body": {
"type": "BlockStatement",
"span": {
"start": 69,
"end": 72,
"ctxt": 0
},
"stmts": []
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 73,
"end": 120,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 77,
"end": 120,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 77,
"end": 79,
"ctxt": 0
},
"value": "f3",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ArrowFunctionExpression",
"span": {
"start": 82,
"end": 120,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 83,
"end": 92,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 84,
"end": 92,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 86,
"end": 92,
"ctxt": 0
},
"kind": "string"
}
}
},
{
"type": "Identifier",
"span": {
"start": 94,
"end": 103,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 95,
"end": 103,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 97,
"end": 103,
"ctxt": 0
},
"kind": "number"
}
}
},
{
"type": "RestElement",
"span": {
"start": 108,
"end": 112,
"ctxt": 0
},
"rest": {
"start": 105,
"end": 108,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 108,
"end": 112,
"ctxt": 0
},
"value": "rest",
"optional": false,
"typeAnnotation": null
},
"typeAnnotation": null
}
],
"body": {
"type": "BlockStatement",
"span": {
"start": 117,
"end": 120,
"ctxt": 0
},
"stmts": []
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 121,
"end": 167,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 125,
"end": 167,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 125,
"end": 127,
"ctxt": 0
},
"value": "f4",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ArrowFunctionExpression",
"span": {
"start": 130,
"end": 167,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 131,
"end": 140,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 132,
"end": 140,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 134,
"end": 140,
"ctxt": 0
},
"kind": "string"
}
}
},
{
"type": "Identifier",
"span": {
"start": 142,
"end": 151,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 143,
"end": 151,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 145,
"end": 151,
"ctxt": 0
},
"kind": "number"
}
}
},
{
"type": "AssignmentPattern",
"span": {
"start": 153,
"end": 159,
"ctxt": 0
},
"left": {
"type": "Identifier",
"span": {
"start": 153,
"end": 154,
"ctxt": 0
},
"value": "z",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 157,
"end": 159,
"ctxt": 0
},
"value": 10.0
},
"typeAnnotation": null
}
],
"body": {
"type": "BlockStatement",
"span": {
"start": 164,
"end": 167,
"ctxt": 0
},
"stmts": []
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
},
"definite": false
}
]
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 177,
"end": 180,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 181,
"end": 200,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 181,
"end": 200,
"ctxt": 0
},
"value": "func",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 185,
"end": 200,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsFunctionType",
"span": {
"start": 187,
"end": 200,
"ctxt": 0
},
"params": [],
"typeParams": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 190,
"end": 200,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 193,
"end": 200,
"ctxt": 0
},
"kind": "boolean"
}
}
}
}
}
}
],
"decorators": [],
"span": {
"start": 168,
"end": 205,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 202,
"end": 205,
"ctxt": 0
},
"stmts": []
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
{
"type": "ExpressionStatement",
"span": {
"start": 206,
"end": 222,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 206,
"end": 221,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 206,
"end": 209,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 210,
"end": 220,
"ctxt": 0
},
"params": [],
"body": {
"type": "BooleanLiteral",
"span": {
"start": 216,
"end": 220,
"ctxt": 0
},
"value": true
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
}
],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 223,
"end": 252,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 223,
"end": 251,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 223,
"end": 226,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 227,
"end": 250,
"ctxt": 0
},
"params": [],
"body": {
"type": "BlockStatement",
"span": {
"start": 233,
"end": 250,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 235,
"end": 248,
"ctxt": 0
},
"argument": {
"type": "BooleanLiteral",
"span": {
"start": 242,
"end": 247,
"ctxt": 0
},
"value": false
}
}
]
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
}
],
"typeArguments": null
}
}
],
"interpreter": null
}