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

999 lines
24 KiB
JSON

{
"type": "Script",
"span": {
"start": 77,
"end": 507,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 77,
"end": 108,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 87,
"end": 91,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 92,
"end": 108,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 94,
"end": 106,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 94,
"end": 97,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 97,
"end": 105,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 99,
"end": 105,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 109,
"end": 156,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 119,
"end": 126,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 135,
"end": 139,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 135,
"end": 139,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 140,
"end": 156,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 142,
"end": 154,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 142,
"end": 145,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 145,
"end": 153,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 147,
"end": 153,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 158,
"end": 189,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 168,
"end": 169,
"ctxt": 0
},
"value": "T",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 170,
"end": 189,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 176,
"end": 187,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 176,
"end": 179,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 180,
"end": 186,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 182,
"end": 186,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 182,
"end": 186,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 191,
"end": 240,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 201,
"end": 202,
"ctxt": 0
},
"value": "S",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 211,
"end": 212,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 211,
"end": 212,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 213,
"end": 240,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 219,
"end": 232,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 219,
"end": 223,
"ctxt": 0
},
"value": "Foo2",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 223,
"end": 232,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 225,
"end": 232,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 225,
"end": 232,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 242,
"end": 272,
"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": 272,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 261,
"end": 270,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
"start": 261,
"end": 262,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 263,
"end": 269,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 265,
"end": 269,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 265,
"end": 269,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 274,
"end": 323,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 284,
"end": 286,
"ctxt": 0
},
"value": "S2",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 295,
"end": 297,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 295,
"end": 297,
"ctxt": 0
},
"value": "T2",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 298,
"end": 323,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 304,
"end": 315,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
"start": 304,
"end": 305,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
},
"computed": false,
"optional": false,
"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": 325,
"end": 357,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 335,
"end": 337,
"ctxt": 0
},
"value": "T3",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 338,
"end": 357,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 344,
"end": 355,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "StringLiteral",
"span": {
"start": 344,
"end": 347,
"ctxt": 0
},
"value": "1",
"raw": "'1'"
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 348,
"end": 354,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 350,
"end": 354,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 350,
"end": 354,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 359,
"end": 412,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 369,
"end": 371,
"ctxt": 0
},
"value": "S3",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 380,
"end": 382,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 380,
"end": 382,
"ctxt": 0
},
"value": "T3",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 383,
"end": 412,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 389,
"end": 404,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "StringLiteral",
"span": {
"start": 389,
"end": 394,
"ctxt": 0
},
"value": "1.0",
"raw": "'1.0'"
},
"computed": false,
"optional": false,
"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": 437,
"end": 459,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 441,
"end": 459,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 441,
"end": 442,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 442,
"end": 459,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 444,
"end": 459,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 446,
"end": 457,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 446,
"end": 449,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 450,
"end": 456,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 452,
"end": 456,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 452,
"end": 456,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 460,
"end": 485,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 464,
"end": 485,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 464,
"end": 465,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 465,
"end": 485,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 467,
"end": 485,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 469,
"end": 483,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 469,
"end": 473,
"ctxt": 0
},
"value": "Foo2",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 473,
"end": 482,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 475,
"end": 482,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 475,
"end": 482,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 486,
"end": 507,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 490,
"end": 506,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 490,
"end": 491,
"ctxt": 0
},
"value": "r",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ConditionalExpression",
"span": {
"start": 494,
"end": 506,
"ctxt": 0
},
"test": {
"type": "BooleanLiteral",
"span": {
"start": 494,
"end": 498,
"ctxt": 0
},
"value": true
},
"consequent": {
"type": "Identifier",
"span": {
"start": 501,
"end": 502,
"ctxt": 0
},
"value": "a",
"optional": false
},
"alternate": {
"type": "Identifier",
"span": {
"start": 505,
"end": 506,
"ctxt": 0
},
"value": "b",
"optional": false
}
},
"definite": false
}
]
}
],
"interpreter": null
}