swc/crates/swc_ecma_parser/tests/tsc/genericFunctionParameters.json
2022-02-04 20:17:42 +09:00

1367 lines
40 KiB
JSON

{
"type": "Script",
"span": {
"start": 40,
"end": 422,
"ctxt": 0
},
"body": [
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 57,
"end": 59,
"ctxt": 0
},
"value": "f1",
"optional": false
},
"declare": true,
"params": [
{
"type": "Parameter",
"span": {
"start": 63,
"end": 81,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 63,
"end": 81,
"ctxt": 0
},
"value": "cb",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 65,
"end": 81,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsFunctionType",
"span": {
"start": 67,
"end": 81,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 71,
"end": 75,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 72,
"end": 75,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 74,
"end": 75,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 74,
"end": 75,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
}
}
],
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 67,
"end": 70,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 68,
"end": 69,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 68,
"end": 69,
"ctxt": 0
},
"value": "S",
"optional": false
},
"constraint": null,
"default": null
}
]
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 77,
"end": 81,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 80,
"end": 81,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 80,
"end": 81,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
}
}
],
"decorators": [],
"span": {
"start": 40,
"end": 86,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 59,
"end": 62,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 60,
"end": 61,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 60,
"end": 61,
"ctxt": 0
},
"value": "T",
"optional": false
},
"constraint": null,
"default": null
}
]
},
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 82,
"end": 85,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 84,
"end": 85,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 84,
"end": 85,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 104,
"end": 106,
"ctxt": 0
},
"value": "f2",
"optional": false
},
"declare": true,
"params": [
{
"type": "Parameter",
"span": {
"start": 110,
"end": 143,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 110,
"end": 143,
"ctxt": 0
},
"value": "cb",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 112,
"end": 143,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsFunctionType",
"span": {
"start": 114,
"end": 143,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 133,
"end": 137,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 134,
"end": 137,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 136,
"end": 137,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 136,
"end": 137,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
}
}
],
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 114,
"end": 132,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 115,
"end": 131,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 115,
"end": 116,
"ctxt": 0
},
"value": "S",
"optional": false
},
"constraint": {
"type": "TsKeywordType",
"span": {
"start": 125,
"end": 131,
"ctxt": 0
},
"kind": "number"
},
"default": null
}
]
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 139,
"end": 143,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 142,
"end": 143,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 142,
"end": 143,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
}
}
],
"decorators": [],
"span": {
"start": 87,
"end": 148,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 106,
"end": 109,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 107,
"end": 108,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 107,
"end": 108,
"ctxt": 0
},
"value": "T",
"optional": false
},
"constraint": null,
"default": null
}
]
},
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 144,
"end": 147,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 146,
"end": 147,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 146,
"end": 147,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 166,
"end": 168,
"ctxt": 0
},
"value": "f3",
"optional": false
},
"declare": true,
"params": [
{
"type": "Parameter",
"span": {
"start": 172,
"end": 207,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 172,
"end": 207,
"ctxt": 0
},
"value": "cb",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 174,
"end": 207,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsFunctionType",
"span": {
"start": 176,
"end": 207,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 197,
"end": 201,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 198,
"end": 201,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 200,
"end": 201,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 200,
"end": 201,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
}
}
],
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 176,
"end": 196,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 177,
"end": 195,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 177,
"end": 178,
"ctxt": 0
},
"value": "S",
"optional": false
},
"constraint": {
"type": "TsTypeReference",
"span": {
"start": 187,
"end": 195,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 187,
"end": 192,
"ctxt": 0
},
"value": "Array",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 192,
"end": 195,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 193,
"end": 194,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 193,
"end": 194,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
]
}
},
"default": null
}
]
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 203,
"end": 207,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 206,
"end": 207,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 206,
"end": 207,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
}
}
],
"decorators": [],
"span": {
"start": 149,
"end": 212,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 168,
"end": 171,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 169,
"end": 170,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 169,
"end": 170,
"ctxt": 0
},
"value": "T",
"optional": false
},
"constraint": null,
"default": null
}
]
},
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 208,
"end": 211,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 210,
"end": 211,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 210,
"end": 211,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 214,
"end": 234,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 218,
"end": 233,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 218,
"end": 220,
"ctxt": 0
},
"value": "x1",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 223,
"end": 233,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 223,
"end": 225,
"ctxt": 0
},
"value": "f1",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 226,
"end": 232,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 226,
"end": 227,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
}
],
"body": {
"type": "Identifier",
"span": {
"start": 231,
"end": 232,
"ctxt": 0
},
"value": "x",
"optional": false
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 242,
"end": 262,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 246,
"end": 261,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 246,
"end": 248,
"ctxt": 0
},
"value": "x2",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 251,
"end": 261,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 251,
"end": 253,
"ctxt": 0
},
"value": "f2",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 254,
"end": 260,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 254,
"end": 255,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
}
],
"body": {
"type": "Identifier",
"span": {
"start": 259,
"end": 260,
"ctxt": 0
},
"value": "x",
"optional": false
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 274,
"end": 294,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 278,
"end": 293,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 278,
"end": 280,
"ctxt": 0
},
"value": "x3",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 283,
"end": 293,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 283,
"end": 285,
"ctxt": 0
},
"value": "f3",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 286,
"end": 292,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 286,
"end": 287,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
}
],
"body": {
"type": "Identifier",
"span": {
"start": 291,
"end": 292,
"ctxt": 0
},
"value": "x",
"optional": false
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 333,
"end": 394,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 347,
"end": 393,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 347,
"end": 348,
"ctxt": 0
},
"value": "s",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 348,
"end": 393,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsFunctionType",
"span": {
"start": 350,
"end": 393,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 354,
"end": 387,
"ctxt": 0
},
"value": "go",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 356,
"end": 387,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsFunctionType",
"span": {
"start": 358,
"end": 387,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 362,
"end": 381,
"ctxt": 0
},
"value": "ops",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 365,
"end": 381,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 367,
"end": 381,
"ctxt": 0
},
"members": [
{
"type": "TsMethodSignature",
"span": {
"start": 369,
"end": 379,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 369,
"end": 373,
"ctxt": 0
},
"value": "init",
"optional": false
},
"computed": false,
"optional": false,
"params": [],
"typeAnn": {
"type": "TsTypeAnnotation",
"span": {
"start": 375,
"end": 378,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 377,
"end": 378,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 377,
"end": 378,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
}
],
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 358,
"end": 361,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 359,
"end": 360,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 359,
"end": 360,
"ctxt": 0
},
"value": "S",
"optional": false
},
"constraint": null,
"default": null
}
]
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 383,
"end": 387,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 386,
"end": 387,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 386,
"end": 387,
"ctxt": 0
},
"value": "R",
"optional": false
},
"typeParams": null
}
}
}
}
}
],
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 350,
"end": 353,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 351,
"end": 352,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 351,
"end": 352,
"ctxt": 0
},
"value": "R",
"optional": false
},
"constraint": null,
"default": null
}
]
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 389,
"end": 393,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 392,
"end": 393,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 392,
"end": 393,
"ctxt": 0
},
"value": "R",
"optional": false
},
"typeParams": null
}
}
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 395,
"end": 422,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 401,
"end": 421,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 401,
"end": 402,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 405,
"end": 421,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 405,
"end": 406,
"ctxt": 0
},
"value": "s",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 407,
"end": 420,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 407,
"end": 408,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": null
}
],
"body": {
"type": "CallExpression",
"span": {
"start": 412,
"end": 420,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 412,
"end": 418,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 412,
"end": 413,
"ctxt": 0
},
"value": "a",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 414,
"end": 418,
"ctxt": 0
},
"value": "init",
"optional": false
}
},
"arguments": [],
"typeArguments": null
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
}
],
"typeArguments": null
},
"definite": false
}
]
}
],
"interpreter": null
}