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

1383 lines
40 KiB
JSON

{
"type": "Script",
"span": {
"start": 41,
"end": 423,
"ctxt": 0
},
"body": [
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 58,
"end": 60,
"ctxt": 0
},
"value": "f1",
"optional": false
},
"declare": true,
"params": [
{
"type": "Parameter",
"span": {
"start": 64,
"end": 82,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 64,
"end": 82,
"ctxt": 0
},
"value": "cb",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 66,
"end": 82,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsFunctionType",
"span": {
"start": 68,
"end": 82,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 72,
"end": 76,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 73,
"end": 76,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 75,
"end": 76,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 75,
"end": 76,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
}
}
],
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 68,
"end": 71,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 69,
"end": 70,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 69,
"end": 70,
"ctxt": 0
},
"value": "S",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 78,
"end": 82,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 81,
"end": 82,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 81,
"end": 82,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
}
}
],
"decorators": [],
"span": {
"start": 41,
"end": 87,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 60,
"end": 63,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 61,
"end": 62,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 61,
"end": 62,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
},
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 83,
"end": 86,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 85,
"end": 86,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 85,
"end": 86,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 105,
"end": 107,
"ctxt": 0
},
"value": "f2",
"optional": false
},
"declare": true,
"params": [
{
"type": "Parameter",
"span": {
"start": 111,
"end": 144,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 111,
"end": 144,
"ctxt": 0
},
"value": "cb",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 113,
"end": 144,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsFunctionType",
"span": {
"start": 115,
"end": 144,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 134,
"end": 138,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 135,
"end": 138,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 137,
"end": 138,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 137,
"end": 138,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
}
}
],
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 115,
"end": 133,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 116,
"end": 132,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 116,
"end": 117,
"ctxt": 0
},
"value": "S",
"optional": false
},
"in": false,
"out": false,
"constraint": {
"type": "TsKeywordType",
"span": {
"start": 126,
"end": 132,
"ctxt": 0
},
"kind": "number"
},
"default": null
}
]
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 140,
"end": 144,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 143,
"end": 144,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 143,
"end": 144,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
}
}
],
"decorators": [],
"span": {
"start": 88,
"end": 149,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 107,
"end": 110,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 108,
"end": 109,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 108,
"end": 109,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
},
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 145,
"end": 148,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 147,
"end": 148,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 147,
"end": 148,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 167,
"end": 169,
"ctxt": 0
},
"value": "f3",
"optional": false
},
"declare": true,
"params": [
{
"type": "Parameter",
"span": {
"start": 173,
"end": 208,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 173,
"end": 208,
"ctxt": 0
},
"value": "cb",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 175,
"end": 208,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsFunctionType",
"span": {
"start": 177,
"end": 208,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 198,
"end": 202,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 199,
"end": 202,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 201,
"end": 202,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 201,
"end": 202,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
}
}
],
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 177,
"end": 197,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 178,
"end": 196,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 178,
"end": 179,
"ctxt": 0
},
"value": "S",
"optional": false
},
"in": false,
"out": false,
"constraint": {
"type": "TsTypeReference",
"span": {
"start": 188,
"end": 196,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 188,
"end": 193,
"ctxt": 0
},
"value": "Array",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 193,
"end": 196,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 194,
"end": 195,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 194,
"end": 195,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
]
}
},
"default": null
}
]
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 204,
"end": 208,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 207,
"end": 208,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 207,
"end": 208,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
}
}
],
"decorators": [],
"span": {
"start": 150,
"end": 213,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 169,
"end": 172,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 170,
"end": 171,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 170,
"end": 171,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
},
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 209,
"end": 212,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 211,
"end": 212,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 211,
"end": 212,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 215,
"end": 235,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 219,
"end": 234,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 219,
"end": 221,
"ctxt": 0
},
"value": "x1",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 224,
"end": 234,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 224,
"end": 226,
"ctxt": 0
},
"value": "f1",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 227,
"end": 233,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 227,
"end": 228,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
}
],
"body": {
"type": "Identifier",
"span": {
"start": 232,
"end": 233,
"ctxt": 0
},
"value": "x",
"optional": false
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 243,
"end": 263,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 247,
"end": 262,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 247,
"end": 249,
"ctxt": 0
},
"value": "x2",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 252,
"end": 262,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 252,
"end": 254,
"ctxt": 0
},
"value": "f2",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 255,
"end": 261,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 255,
"end": 256,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
}
],
"body": {
"type": "Identifier",
"span": {
"start": 260,
"end": 261,
"ctxt": 0
},
"value": "x",
"optional": false
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 275,
"end": 295,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 279,
"end": 294,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 279,
"end": 281,
"ctxt": 0
},
"value": "x3",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 284,
"end": 294,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 284,
"end": 286,
"ctxt": 0
},
"value": "f3",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 287,
"end": 293,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 287,
"end": 288,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
}
],
"body": {
"type": "Identifier",
"span": {
"start": 292,
"end": 293,
"ctxt": 0
},
"value": "x",
"optional": false
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 334,
"end": 395,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 348,
"end": 394,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 348,
"end": 349,
"ctxt": 0
},
"value": "s",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 349,
"end": 394,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsFunctionType",
"span": {
"start": 351,
"end": 394,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 355,
"end": 388,
"ctxt": 0
},
"value": "go",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 357,
"end": 388,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsFunctionType",
"span": {
"start": 359,
"end": 388,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 363,
"end": 382,
"ctxt": 0
},
"value": "ops",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 366,
"end": 382,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 368,
"end": 382,
"ctxt": 0
},
"members": [
{
"type": "TsMethodSignature",
"span": {
"start": 370,
"end": 380,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 370,
"end": 374,
"ctxt": 0
},
"value": "init",
"optional": false
},
"computed": false,
"optional": false,
"params": [],
"typeAnn": {
"type": "TsTypeAnnotation",
"span": {
"start": 376,
"end": 379,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 378,
"end": 379,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 378,
"end": 379,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
}
],
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 359,
"end": 362,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 360,
"end": 361,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 360,
"end": 361,
"ctxt": 0
},
"value": "S",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 384,
"end": 388,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 387,
"end": 388,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 387,
"end": 388,
"ctxt": 0
},
"value": "R",
"optional": false
},
"typeParams": null
}
}
}
}
}
],
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 351,
"end": 354,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 352,
"end": 353,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 352,
"end": 353,
"ctxt": 0
},
"value": "R",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 390,
"end": 394,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 393,
"end": 394,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 393,
"end": 394,
"ctxt": 0
},
"value": "R",
"optional": false
},
"typeParams": null
}
}
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 396,
"end": 423,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 402,
"end": 422,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 402,
"end": 403,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 406,
"end": 422,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 406,
"end": 407,
"ctxt": 0
},
"value": "s",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 408,
"end": 421,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 408,
"end": 409,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": null
}
],
"body": {
"type": "CallExpression",
"span": {
"start": 413,
"end": 421,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 413,
"end": 419,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 413,
"end": 414,
"ctxt": 0
},
"value": "a",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 415,
"end": 419,
"ctxt": 0
},
"value": "init",
"optional": false
}
},
"arguments": [],
"typeArguments": null
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
}
],
"typeArguments": null
},
"definite": false
}
]
}
],
"interpreter": null
}