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

999 lines
24 KiB
JSON

{
"type": "Script",
"span": {
"start": 75,
"end": 510,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 75,
"end": 106,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 85,
"end": 89,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 90,
"end": 106,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 92,
"end": 104,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 92,
"end": 95,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 95,
"end": 103,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 97,
"end": 103,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 107,
"end": 154,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 117,
"end": 124,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 133,
"end": 137,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 133,
"end": 137,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 138,
"end": 154,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 140,
"end": 152,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 140,
"end": 143,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 143,
"end": 151,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 145,
"end": 151,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 156,
"end": 186,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 166,
"end": 167,
"ctxt": 0
},
"value": "T",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 168,
"end": 186,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 174,
"end": 184,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 174,
"end": 177,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 177,
"end": 183,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 179,
"end": 183,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 179,
"end": 183,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 188,
"end": 240,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 198,
"end": 199,
"ctxt": 0
},
"value": "S",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 208,
"end": 209,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 208,
"end": 209,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 210,
"end": 240,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 216,
"end": 229,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 216,
"end": 219,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 220,
"end": 229,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 222,
"end": 229,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 222,
"end": 229,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 242,
"end": 271,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 252,
"end": 254,
"ctxt": 0
},
"value": "T2",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 255,
"end": 271,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 261,
"end": 269,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
"start": 261,
"end": 262,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 262,
"end": 268,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 264,
"end": 268,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 264,
"end": 268,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 273,
"end": 326,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 283,
"end": 285,
"ctxt": 0
},
"value": "S2",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 294,
"end": 296,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 294,
"end": 296,
"ctxt": 0
},
"value": "T2",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 297,
"end": 326,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 303,
"end": 315,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
"start": 303,
"end": 304,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 305,
"end": 314,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 307,
"end": 314,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 307,
"end": 314,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 328,
"end": 359,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 338,
"end": 340,
"ctxt": 0
},
"value": "T3",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 341,
"end": 359,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 347,
"end": 357,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "StringLiteral",
"span": {
"start": 347,
"end": 350,
"ctxt": 0
},
"value": "1",
"raw": "'1'"
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 350,
"end": 356,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 352,
"end": 356,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 352,
"end": 356,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 361,
"end": 416,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 371,
"end": 373,
"ctxt": 0
},
"value": "S3",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 382,
"end": 384,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 382,
"end": 384,
"ctxt": 0
},
"value": "T3",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 385,
"end": 416,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 391,
"end": 405,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "StringLiteral",
"span": {
"start": 391,
"end": 394,
"ctxt": 0
},
"value": "1",
"raw": "'1'"
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 395,
"end": 404,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 397,
"end": 404,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 397,
"end": 404,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 441,
"end": 462,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 445,
"end": 462,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 445,
"end": 446,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 446,
"end": 462,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 448,
"end": 462,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 450,
"end": 460,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 450,
"end": 453,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 453,
"end": 459,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 455,
"end": 459,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 455,
"end": 459,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 463,
"end": 488,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 467,
"end": 488,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 467,
"end": 468,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 468,
"end": 488,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 470,
"end": 488,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 472,
"end": 486,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 472,
"end": 475,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 476,
"end": 485,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 478,
"end": 485,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 478,
"end": 485,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 489,
"end": 510,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 493,
"end": 509,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 493,
"end": 494,
"ctxt": 0
},
"value": "r",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ConditionalExpression",
"span": {
"start": 497,
"end": 509,
"ctxt": 0
},
"test": {
"type": "BooleanLiteral",
"span": {
"start": 497,
"end": 501,
"ctxt": 0
},
"value": true
},
"consequent": {
"type": "Identifier",
"span": {
"start": 504,
"end": 505,
"ctxt": 0
},
"value": "a",
"optional": false
},
"alternate": {
"type": "Identifier",
"span": {
"start": 508,
"end": 509,
"ctxt": 0
},
"value": "b",
"optional": false
}
},
"definite": false
}
]
}
],
"interpreter": null
}