swc/crates/swc_ecma_parser/tests/tsc/variance.json
2022-02-04 17:08:38 +09:00

962 lines
26 KiB
JSON

{
"type": "Script",
"span": {
"start": 116,
"end": 528,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 116,
"end": 180,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 126,
"end": 129,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"declare": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 129,
"end": 132,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 130,
"end": 131,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 130,
"end": 131,
"ctxt": 0
},
"value": "T",
"optional": false
},
"constraint": null,
"default": null
}
]
},
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 133,
"end": 180,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 138,
"end": 177,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 138,
"end": 142,
"ctxt": 0
},
"value": "prop",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 142,
"end": 176,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsConditionalType",
"span": {
"start": 144,
"end": 176,
"ctxt": 0
},
"checkType": {
"type": "TsTypeReference",
"span": {
"start": 144,
"end": 145,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 144,
"end": 145,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
},
"extendsType": {
"type": "TsKeywordType",
"span": {
"start": 154,
"end": 161,
"ctxt": 0
},
"kind": "unknown"
},
"trueType": {
"type": "TsLiteralType",
"span": {
"start": 164,
"end": 168,
"ctxt": 0
},
"literal": {
"type": "BooleanLiteral",
"span": {
"start": 164,
"end": 168,
"ctxt": 0
},
"value": true
}
},
"falseType": {
"type": "TsLiteralType",
"span": {
"start": 171,
"end": 176,
"ctxt": 0
},
"literal": {
"type": "BooleanLiteral",
"span": {
"start": 171,
"end": 176,
"ctxt": 0
},
"value": false
}
}
}
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 184,
"end": 220,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 190,
"end": 219,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 190,
"end": 193,
"ctxt": 0
},
"value": "foo",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "TsConstAssertion",
"span": {
"start": 196,
"end": 219,
"ctxt": 0
},
"expression": {
"type": "ObjectExpression",
"span": {
"start": 196,
"end": 210,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 198,
"end": 202,
"ctxt": 0
},
"value": "prop",
"optional": false
},
"value": {
"type": "BooleanLiteral",
"span": {
"start": 204,
"end": 208,
"ctxt": 0
},
"value": true
}
}
]
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 222,
"end": 244,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 228,
"end": 243,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 228,
"end": 229,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 229,
"end": 237,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 231,
"end": 237,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 231,
"end": 234,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 234,
"end": 237,
"ctxt": 0
},
"params": [
{
"type": "TsLiteralType",
"span": {
"start": 235,
"end": 236,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 235,
"end": 236,
"ctxt": 0
},
"value": 1.0
}
}
]
}
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 240,
"end": 243,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 246,
"end": 273,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 252,
"end": 272,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 252,
"end": 253,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 253,
"end": 266,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 255,
"end": 266,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 255,
"end": 258,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 258,
"end": 266,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 259,
"end": 265,
"ctxt": 0
},
"kind": "number"
}
]
}
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 269,
"end": 272,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 275,
"end": 300,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 281,
"end": 299,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 281,
"end": 282,
"ctxt": 0
},
"value": "z",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 282,
"end": 295,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 284,
"end": 295,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 284,
"end": 287,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 287,
"end": 295,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 288,
"end": 294,
"ctxt": 0
},
"kind": "number"
}
]
}
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 298,
"end": 299,
"ctxt": 0
},
"value": "x",
"optional": false
},
"definite": false
}
]
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 336,
"end": 339,
"ctxt": 0
},
"value": "Bar",
"optional": false
},
"declare": false,
"span": {
"start": 330,
"end": 528,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 363,
"end": 407,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 378,
"end": 386,
"ctxt": 0
},
"value": "instance",
"optional": false
},
"value": {
"type": "ArrayExpression",
"span": {
"start": 404,
"end": 406,
"ctxt": 0
},
"elements": []
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 386,
"end": 401,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsArrayType",
"span": {
"start": 388,
"end": 401,
"ctxt": 0
},
"elemType": {
"type": "TsTypeReference",
"span": {
"start": 388,
"end": 399,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 388,
"end": 391,
"ctxt": 0
},
"value": "Bar",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 391,
"end": 399,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 392,
"end": 398,
"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": 413,
"end": 470,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 413,
"end": 417,
"ctxt": 0
},
"value": "cast",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 418,
"end": 465,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 418,
"end": 465,
"ctxt": 0
},
"value": "_name",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 423,
"end": 465,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsParenthesizedType",
"span": {
"start": 425,
"end": 465,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsConditionalType",
"span": {
"start": 426,
"end": 464,
"ctxt": 0
},
"checkType": {
"type": "TsTupleType",
"span": {
"start": 426,
"end": 429,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 427,
"end": 428,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsTypeReference",
"span": {
"start": 427,
"end": 428,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 427,
"end": 428,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
]
},
"extendsType": {
"type": "TsTupleType",
"span": {
"start": 438,
"end": 446,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 439,
"end": 445,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 439,
"end": 445,
"ctxt": 0
},
"kind": "string"
}
}
]
},
"trueType": {
"type": "TsKeywordType",
"span": {
"start": 449,
"end": 455,
"ctxt": 0
},
"kind": "string"
},
"falseType": {
"type": "TsKeywordType",
"span": {
"start": 458,
"end": 464,
"ctxt": 0
},
"kind": "string"
}
}
}
}
}
}
],
"decorators": [],
"span": {
"start": 413,
"end": 470,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 467,
"end": 470,
"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": 478,
"end": 525,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 478,
"end": 486,
"ctxt": 0
},
"value": "pushThis",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 478,
"end": 525,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 489,
"end": 525,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 496,
"end": 520,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 496,
"end": 519,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 496,
"end": 513,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 496,
"end": 508,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 496,
"end": 499,
"ctxt": 0
},
"value": "Bar",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 500,
"end": 508,
"ctxt": 0
},
"value": "instance",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 509,
"end": 513,
"ctxt": 0
},
"value": "push",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ThisExpression",
"span": {
"start": 514,
"end": 518,
"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": 339,
"end": 357,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 340,
"end": 356,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 340,
"end": 341,
"ctxt": 0
},
"value": "T",
"optional": false
},
"constraint": {
"type": "TsKeywordType",
"span": {
"start": 350,
"end": 356,
"ctxt": 0
},
"kind": "string"
},
"default": null
}
]
},
"superTypeParams": null,
"implements": []
}
],
"interpreter": null
}