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

999 lines
24 KiB
JSON

{
"type": "Script",
"span": {
"start": 78,
"end": 509,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 78,
"end": 109,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 88,
"end": 92,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 93,
"end": 109,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 95,
"end": 107,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 95,
"end": 98,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 98,
"end": 106,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 100,
"end": 106,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 110,
"end": 157,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 120,
"end": 127,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 136,
"end": 140,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 136,
"end": 140,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 141,
"end": 157,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 143,
"end": 155,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 143,
"end": 146,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 146,
"end": 154,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 148,
"end": 154,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 159,
"end": 189,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 169,
"end": 170,
"ctxt": 0
},
"value": "T",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 171,
"end": 189,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 177,
"end": 187,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 177,
"end": 180,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": false,
"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": 241,
"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": 241,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 219,
"end": 233,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 219,
"end": 223,
"ctxt": 0
},
"value": "Foo2",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 224,
"end": 233,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 226,
"end": 233,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 226,
"end": 233,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 243,
"end": 273,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 253,
"end": 255,
"ctxt": 0
},
"value": "T2",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 256,
"end": 273,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 262,
"end": 270,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
"start": 262,
"end": 263,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"computed": false,
"optional": false,
"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": 275,
"end": 325,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 285,
"end": 287,
"ctxt": 0
},
"value": "S2",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 296,
"end": 298,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 296,
"end": 298,
"ctxt": 0
},
"value": "T2",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 299,
"end": 325,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 305,
"end": 317,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
"start": 305,
"end": 306,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 307,
"end": 316,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 309,
"end": 316,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 309,
"end": 316,
"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": 414,
"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": 414,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 390,
"end": 406,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "StringLiteral",
"span": {
"start": 390,
"end": 395,
"ctxt": 0
},
"value": "1.0",
"raw": "'1.0'"
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 396,
"end": 405,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 398,
"end": 405,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 398,
"end": 405,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 439,
"end": 460,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 443,
"end": 460,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 443,
"end": 444,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 444,
"end": 460,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 446,
"end": 460,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 448,
"end": 458,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 448,
"end": 451,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 451,
"end": 457,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 453,
"end": 457,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 453,
"end": 457,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 461,
"end": 487,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 465,
"end": 487,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 465,
"end": 466,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 466,
"end": 487,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 468,
"end": 487,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 470,
"end": 485,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 470,
"end": 474,
"ctxt": 0
},
"value": "Foo2",
"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
}