swc/crates/swc_ecma_parser/tests/tsc/variance.json
2022-04-05 12:46:35 +00:00

967 lines
26 KiB
JSON

{
"type": "Script",
"span": {
"start": 110,
"end": 502,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 110,
"end": 172,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 120,
"end": 123,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"declare": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 123,
"end": 126,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 124,
"end": 125,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 124,
"end": 125,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
},
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 127,
"end": 172,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 131,
"end": 170,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 131,
"end": 135,
"ctxt": 0
},
"value": "prop",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 135,
"end": 169,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsConditionalType",
"span": {
"start": 137,
"end": 169,
"ctxt": 0
},
"checkType": {
"type": "TsTypeReference",
"span": {
"start": 137,
"end": 138,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 137,
"end": 138,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
},
"extendsType": {
"type": "TsKeywordType",
"span": {
"start": 147,
"end": 154,
"ctxt": 0
},
"kind": "unknown"
},
"trueType": {
"type": "TsLiteralType",
"span": {
"start": 157,
"end": 161,
"ctxt": 0
},
"literal": {
"type": "BooleanLiteral",
"span": {
"start": 157,
"end": 161,
"ctxt": 0
},
"value": true
}
},
"falseType": {
"type": "TsLiteralType",
"span": {
"start": 164,
"end": 169,
"ctxt": 0
},
"literal": {
"type": "BooleanLiteral",
"span": {
"start": 164,
"end": 169,
"ctxt": 0
},
"value": false
}
}
}
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 174,
"end": 210,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 180,
"end": 209,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 180,
"end": 183,
"ctxt": 0
},
"value": "foo",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "TsConstAssertion",
"span": {
"start": 186,
"end": 209,
"ctxt": 0
},
"expression": {
"type": "ObjectExpression",
"span": {
"start": 186,
"end": 200,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 188,
"end": 192,
"ctxt": 0
},
"value": "prop",
"optional": false
},
"value": {
"type": "BooleanLiteral",
"span": {
"start": 194,
"end": 198,
"ctxt": 0
},
"value": true
}
}
]
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 211,
"end": 233,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 217,
"end": 232,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 217,
"end": 218,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 218,
"end": 226,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 220,
"end": 226,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 220,
"end": 223,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 223,
"end": 226,
"ctxt": 0
},
"params": [
{
"type": "TsLiteralType",
"span": {
"start": 224,
"end": 225,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 224,
"end": 225,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
}
]
}
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 229,
"end": 232,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 234,
"end": 261,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 240,
"end": 260,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 240,
"end": 241,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 241,
"end": 254,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 243,
"end": 254,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 243,
"end": 246,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 246,
"end": 254,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 247,
"end": 253,
"ctxt": 0
},
"kind": "number"
}
]
}
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 257,
"end": 260,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 262,
"end": 287,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 268,
"end": 286,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 268,
"end": 269,
"ctxt": 0
},
"value": "z",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 269,
"end": 282,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 271,
"end": 282,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 271,
"end": 274,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 274,
"end": 282,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 275,
"end": 281,
"ctxt": 0
},
"kind": "number"
}
]
}
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 285,
"end": 286,
"ctxt": 0
},
"value": "x",
"optional": false
},
"definite": false
}
]
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 318,
"end": 321,
"ctxt": 0
},
"value": "Bar",
"optional": false
},
"declare": false,
"span": {
"start": 312,
"end": 502,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 344,
"end": 388,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 359,
"end": 367,
"ctxt": 0
},
"value": "instance",
"optional": false
},
"value": {
"type": "ArrayExpression",
"span": {
"start": 385,
"end": 387,
"ctxt": 0
},
"elements": []
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 367,
"end": 382,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsArrayType",
"span": {
"start": 369,
"end": 382,
"ctxt": 0
},
"elemType": {
"type": "TsTypeReference",
"span": {
"start": 369,
"end": 380,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 369,
"end": 372,
"ctxt": 0
},
"value": "Bar",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 372,
"end": 380,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 373,
"end": 379,
"ctxt": 0
},
"kind": "string"
}
]
}
}
}
},
"isStatic": true,
"decorators": [],
"accessibility": "private",
"isAbstract": false,
"isOptional": false,
"isOverride": false,
"readonly": false,
"declare": false,
"definite": false
},
{
"type": "ClassMethod",
"span": {
"start": 392,
"end": 449,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 392,
"end": 396,
"ctxt": 0
},
"value": "cast",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 397,
"end": 444,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 397,
"end": 444,
"ctxt": 0
},
"value": "_name",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 402,
"end": 444,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsParenthesizedType",
"span": {
"start": 404,
"end": 444,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsConditionalType",
"span": {
"start": 405,
"end": 443,
"ctxt": 0
},
"checkType": {
"type": "TsTupleType",
"span": {
"start": 405,
"end": 408,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 406,
"end": 407,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsTypeReference",
"span": {
"start": 406,
"end": 407,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 406,
"end": 407,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
]
},
"extendsType": {
"type": "TsTupleType",
"span": {
"start": 417,
"end": 425,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 418,
"end": 424,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 418,
"end": 424,
"ctxt": 0
},
"kind": "string"
}
}
]
},
"trueType": {
"type": "TsKeywordType",
"span": {
"start": 428,
"end": 434,
"ctxt": 0
},
"kind": "string"
},
"falseType": {
"type": "TsKeywordType",
"span": {
"start": 437,
"end": 443,
"ctxt": 0
},
"kind": "string"
}
}
}
}
}
}
],
"decorators": [],
"span": {
"start": 392,
"end": 449,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 446,
"end": 449,
"ctxt": 0
},
"stmts": []
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 455,
"end": 500,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 455,
"end": 463,
"ctxt": 0
},
"value": "pushThis",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 455,
"end": 500,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 466,
"end": 500,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 472,
"end": 496,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 472,
"end": 495,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 472,
"end": 489,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 472,
"end": 484,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 472,
"end": 475,
"ctxt": 0
},
"value": "Bar",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 476,
"end": 484,
"ctxt": 0
},
"value": "instance",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 485,
"end": 489,
"ctxt": 0
},
"value": "push",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ThisExpression",
"span": {
"start": 490,
"end": 494,
"ctxt": 0
}
}
}
],
"typeArguments": null
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
}
],
"superClass": null,
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 321,
"end": 339,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 322,
"end": 338,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 322,
"end": 323,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": {
"type": "TsKeywordType",
"span": {
"start": 332,
"end": 338,
"ctxt": 0
},
"kind": "string"
},
"default": null
}
]
},
"superTypeParams": null,
"implements": []
}
],
"interpreter": null
}