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

999 lines
24 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
2022-02-04 14:17:42 +03:00
"start": 76,
"end": 506,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 76,
"end": 107,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 86,
"end": 90,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
2022-02-04 14:17:42 +03:00
"start": 91,
"end": 107,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
2022-02-04 14:17:42 +03:00
"start": 93,
"end": 105,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 93,
"end": 96,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 96,
"end": 104,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 98,
"end": 104,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 108,
"end": 155,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 118,
"end": 125,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
2022-02-04 14:17:42 +03:00
"start": 134,
"end": 138,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 134,
"end": 138,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
2022-02-04 14:17:42 +03:00
"start": 139,
"end": 155,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
2022-02-04 14:17:42 +03:00
"start": 141,
"end": 153,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 141,
"end": 144,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 144,
"end": 152,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 146,
"end": 152,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 157,
"end": 188,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 167,
"end": 168,
"ctxt": 0
},
"value": "T",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
2022-02-04 14:17:42 +03:00
"start": 169,
"end": 188,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
2022-02-04 14:17:42 +03:00
"start": 175,
"end": 186,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 175,
"end": 178,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 179,
"end": 185,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 181,
"end": 185,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 181,
"end": 185,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 190,
"end": 239,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 200,
"end": 201,
"ctxt": 0
},
"value": "S",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
2022-02-04 14:17:42 +03:00
"start": 210,
"end": 211,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 210,
"end": 211,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
2022-02-04 14:17:42 +03:00
"start": 212,
"end": 239,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
2022-02-04 14:17:42 +03:00
"start": 218,
"end": 231,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 218,
"end": 222,
"ctxt": 0
},
"value": "Foo2",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 222,
"end": 231,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 224,
"end": 231,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 224,
"end": 231,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 241,
"end": 271,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 251,
"end": 253,
"ctxt": 0
},
"value": "T2",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
2022-02-04 14:17:42 +03:00
"start": 254,
"end": 271,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
2022-02-04 14:17:42 +03:00
"start": 260,
"end": 269,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 260,
"end": 261,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 262,
"end": 268,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 264,
"end": 268,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 264,
"end": 268,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 273,
"end": 322,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 283,
"end": 285,
"ctxt": 0
},
"value": "S2",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
2022-02-04 14:17:42 +03:00
"start": 294,
"end": 296,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 294,
"end": 296,
"ctxt": 0
},
"value": "T2",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
2022-02-04 14:17:42 +03:00
"start": 297,
"end": 322,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
2022-02-04 14:17:42 +03:00
"start": 303,
"end": 314,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 303,
"end": 304,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 304,
"end": 313,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 306,
"end": 313,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 306,
"end": 313,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 324,
"end": 356,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 334,
"end": 336,
"ctxt": 0
},
"value": "T3",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
2022-02-04 14:17:42 +03:00
"start": 337,
"end": 356,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
2022-02-04 14:17:42 +03:00
"start": 343,
"end": 354,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 343,
"end": 346,
"ctxt": 0
},
"value": "1",
"raw": "'1'"
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 347,
"end": 353,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 349,
"end": 353,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 349,
"end": 353,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 358,
"end": 411,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 368,
"end": 370,
"ctxt": 0
},
"value": "S3",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
2022-02-04 14:17:42 +03:00
"start": 379,
"end": 381,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 379,
"end": 381,
"ctxt": 0
},
"value": "T3",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
2022-02-04 14:17:42 +03:00
"start": 382,
"end": 411,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
2022-02-04 14:17:42 +03:00
"start": 388,
"end": 403,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 388,
"end": 393,
"ctxt": 0
},
"value": "1.0",
"raw": "'1.0'"
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 393,
"end": 402,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 395,
"end": 402,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 395,
"end": 402,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 436,
"end": 458,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
2022-02-04 14:17:42 +03:00
"start": 440,
"end": 458,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 440,
"end": 441,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 441,
"end": 458,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 443,
"end": 458,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
2022-02-04 14:17:42 +03:00
"start": 445,
"end": 456,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 445,
"end": 448,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 449,
"end": 455,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 451,
"end": 455,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 451,
"end": 455,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 459,
"end": 484,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
2022-02-04 14:17:42 +03:00
"start": 463,
"end": 484,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 463,
"end": 464,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 464,
"end": 484,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 466,
"end": 484,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
2022-02-04 14:17:42 +03:00
"start": 468,
"end": 482,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 468,
"end": 472,
"ctxt": 0
},
"value": "Foo2",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 472,
"end": 481,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 474,
"end": 481,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 474,
"end": 481,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 485,
"end": 506,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
2022-02-04 14:17:42 +03:00
"start": 489,
"end": 505,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 489,
"end": 490,
"ctxt": 0
},
"value": "r",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ConditionalExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 493,
"end": 505,
"ctxt": 0
},
"test": {
"type": "BooleanLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 493,
"end": 497,
"ctxt": 0
},
"value": true
},
"consequent": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 500,
"end": 501,
"ctxt": 0
},
"value": "a",
"optional": false
},
"alternate": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 504,
"end": 505,
"ctxt": 0
},
"value": "b",
"optional": false
}
},
"definite": false
}
]
}
],
"interpreter": null
}