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

999 lines
24 KiB
JSON

{
"type": "Script",
"span": {
"start": 74,
"end": 509,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 74,
"end": 105,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 84,
"end": 88,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 89,
"end": 105,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 91,
"end": 103,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 91,
"end": 94,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 94,
"end": 102,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 96,
"end": 102,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 106,
"end": 153,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 116,
"end": 123,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 132,
"end": 136,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 132,
"end": 136,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 137,
"end": 153,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 139,
"end": 151,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 139,
"end": 142,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 142,
"end": 150,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 144,
"end": 150,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 155,
"end": 185,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 165,
"end": 166,
"ctxt": 0
},
"value": "T",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 167,
"end": 185,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 173,
"end": 183,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 173,
"end": 176,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 176,
"end": 182,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 178,
"end": 182,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 178,
"end": 182,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 187,
"end": 239,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 197,
"end": 198,
"ctxt": 0
},
"value": "S",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 207,
"end": 208,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 207,
"end": 208,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 209,
"end": 239,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 215,
"end": 228,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 215,
"end": 218,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 219,
"end": 228,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 221,
"end": 228,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 221,
"end": 228,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 241,
"end": 270,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 251,
"end": 253,
"ctxt": 0
},
"value": "T2",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 254,
"end": 270,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 260,
"end": 268,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
"start": 260,
"end": 261,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 261,
"end": 267,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 263,
"end": 267,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 263,
"end": 267,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 272,
"end": 325,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 282,
"end": 284,
"ctxt": 0
},
"value": "S2",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 293,
"end": 295,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 293,
"end": 295,
"ctxt": 0
},
"value": "T2",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 296,
"end": 325,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 302,
"end": 314,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
"start": 302,
"end": 303,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 304,
"end": 313,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 306,
"end": 313,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 306,
"end": 313,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 327,
"end": 358,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 337,
"end": 339,
"ctxt": 0
},
"value": "T3",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 340,
"end": 358,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 346,
"end": 356,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "StringLiteral",
"span": {
"start": 346,
"end": 349,
"ctxt": 0
},
"value": "1",
"raw": "'1'"
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 349,
"end": 355,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 351,
"end": 355,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 351,
"end": 355,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 360,
"end": 415,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 370,
"end": 372,
"ctxt": 0
},
"value": "S3",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 381,
"end": 383,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 381,
"end": 383,
"ctxt": 0
},
"value": "T3",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 384,
"end": 415,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 390,
"end": 404,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "StringLiteral",
"span": {
"start": 390,
"end": 393,
"ctxt": 0
},
"value": "1",
"raw": "'1'"
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 394,
"end": 403,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 396,
"end": 403,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 396,
"end": 403,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 440,
"end": 461,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 444,
"end": 461,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 444,
"end": 445,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 445,
"end": 461,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 447,
"end": 461,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 449,
"end": 459,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 449,
"end": 452,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 452,
"end": 458,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 454,
"end": 458,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 454,
"end": 458,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 462,
"end": 487,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 466,
"end": 487,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 466,
"end": 467,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 467,
"end": 487,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 469,
"end": 487,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 471,
"end": 485,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 471,
"end": 474,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 475,
"end": 484,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 477,
"end": 484,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 477,
"end": 484,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 488,
"end": 509,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 492,
"end": 508,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 492,
"end": 493,
"ctxt": 0
},
"value": "r",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ConditionalExpression",
"span": {
"start": 496,
"end": 508,
"ctxt": 0
},
"test": {
"type": "BooleanLiteral",
"span": {
"start": 496,
"end": 500,
"ctxt": 0
},
"value": true
},
"consequent": {
"type": "Identifier",
"span": {
"start": 503,
"end": 504,
"ctxt": 0
},
"value": "a",
"optional": false
},
"alternate": {
"type": "Identifier",
"span": {
"start": 507,
"end": 508,
"ctxt": 0
},
"value": "b",
"optional": false
}
},
"definite": false
}
]
}
],
"interpreter": null
}