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

967 lines
26 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
"start": 111,
"end": 503,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 111,
"end": 173,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 121,
"end": 124,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"declare": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 124,
"end": 127,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 125,
"end": 126,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 125,
"end": 126,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
},
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 128,
"end": 173,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 132,
"end": 171,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 132,
"end": 136,
"ctxt": 0
},
"value": "prop",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 136,
"end": 170,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsConditionalType",
"span": {
"start": 138,
"end": 170,
"ctxt": 0
},
"checkType": {
"type": "TsTypeReference",
"span": {
"start": 138,
"end": 139,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 138,
"end": 139,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
},
"extendsType": {
"type": "TsKeywordType",
"span": {
"start": 148,
"end": 155,
"ctxt": 0
},
"kind": "unknown"
},
"trueType": {
"type": "TsLiteralType",
"span": {
"start": 158,
"end": 162,
"ctxt": 0
},
"literal": {
"type": "BooleanLiteral",
"span": {
"start": 158,
"end": 162,
"ctxt": 0
},
"value": true
}
},
"falseType": {
"type": "TsLiteralType",
"span": {
"start": 165,
"end": 170,
"ctxt": 0
},
"literal": {
"type": "BooleanLiteral",
"span": {
"start": 165,
"end": 170,
"ctxt": 0
},
"value": false
}
}
}
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 175,
"end": 211,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 181,
"end": 210,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 181,
"end": 184,
"ctxt": 0
},
"value": "foo",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "TsConstAssertion",
"span": {
"start": 187,
"end": 210,
"ctxt": 0
},
"expression": {
"type": "ObjectExpression",
"span": {
"start": 187,
"end": 201,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 189,
"end": 193,
"ctxt": 0
},
"value": "prop",
"optional": false
},
"value": {
"type": "BooleanLiteral",
"span": {
"start": 195,
"end": 199,
"ctxt": 0
},
"value": true
}
}
]
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 212,
"end": 234,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 218,
"end": 233,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 218,
"end": 219,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 219,
"end": 227,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 221,
"end": 227,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 221,
"end": 224,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 224,
"end": 227,
"ctxt": 0
},
"params": [
{
"type": "TsLiteralType",
"span": {
"start": 225,
"end": 226,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 225,
"end": 226,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
}
]
}
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 230,
"end": 233,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 235,
"end": 262,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 241,
"end": 261,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 241,
"end": 242,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 242,
"end": 255,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 244,
"end": 255,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 244,
"end": 247,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 247,
"end": 255,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 248,
"end": 254,
"ctxt": 0
},
"kind": "number"
}
]
}
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 258,
"end": 261,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 263,
"end": 288,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 269,
"end": 287,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 269,
"end": 270,
"ctxt": 0
},
"value": "z",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 270,
"end": 283,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 272,
"end": 283,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 272,
"end": 275,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 275,
"end": 283,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 276,
"end": 282,
"ctxt": 0
},
"kind": "number"
}
]
}
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 286,
"end": 287,
"ctxt": 0
},
"value": "x",
"optional": false
},
"definite": false
}
]
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 319,
"end": 322,
"ctxt": 0
},
"value": "Bar",
"optional": false
},
"declare": false,
"span": {
"start": 313,
"end": 503,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 345,
"end": 389,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 360,
"end": 368,
"ctxt": 0
},
"value": "instance",
"optional": false
},
"value": {
"type": "ArrayExpression",
"span": {
"start": 386,
"end": 388,
"ctxt": 0
},
"elements": []
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 368,
"end": 383,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsArrayType",
"span": {
"start": 370,
"end": 383,
"ctxt": 0
},
"elemType": {
"type": "TsTypeReference",
"span": {
"start": 370,
"end": 381,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 370,
"end": 373,
"ctxt": 0
},
"value": "Bar",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 373,
"end": 381,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 374,
"end": 380,
"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": 393,
"end": 450,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 393,
"end": 397,
"ctxt": 0
},
"value": "cast",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 398,
"end": 445,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 398,
"end": 445,
"ctxt": 0
},
"value": "_name",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 403,
"end": 445,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsParenthesizedType",
"span": {
"start": 405,
"end": 445,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsConditionalType",
"span": {
"start": 406,
"end": 444,
"ctxt": 0
},
"checkType": {
"type": "TsTupleType",
"span": {
"start": 406,
"end": 409,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 407,
"end": 408,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsTypeReference",
"span": {
"start": 407,
"end": 408,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 407,
"end": 408,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
]
},
"extendsType": {
"type": "TsTupleType",
"span": {
"start": 418,
"end": 426,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 419,
"end": 425,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 419,
"end": 425,
"ctxt": 0
},
"kind": "string"
}
}
]
},
"trueType": {
"type": "TsKeywordType",
"span": {
"start": 429,
"end": 435,
"ctxt": 0
},
"kind": "string"
},
"falseType": {
"type": "TsKeywordType",
"span": {
"start": 438,
"end": 444,
"ctxt": 0
},
"kind": "string"
}
}
}
}
}
}
],
"decorators": [],
"span": {
"start": 393,
"end": 450,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 447,
"end": 450,
"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": 456,
"end": 501,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 456,
"end": 464,
"ctxt": 0
},
"value": "pushThis",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 456,
"end": 501,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 467,
"end": 501,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 473,
"end": 497,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 473,
"end": 496,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 473,
"end": 490,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 473,
"end": 485,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 473,
"end": 476,
"ctxt": 0
},
"value": "Bar",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 477,
"end": 485,
"ctxt": 0
},
"value": "instance",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 486,
"end": 490,
"ctxt": 0
},
"value": "push",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ThisExpression",
"span": {
"start": 491,
"end": 495,
"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": 322,
"end": 340,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 323,
"end": 339,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 323,
"end": 324,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": {
"type": "TsKeywordType",
"span": {
"start": 333,
"end": 339,
"ctxt": 0
},
"kind": "string"
},
"default": null
}
]
},
"superTypeParams": null,
"implements": []
}
],
"interpreter": null
}