swc/crates/swc_ecma_parser/tests/tsc/subtypingWithObjectMembersOptionality4.json
2022-02-04 20:17:42 +09:00

1005 lines
24 KiB
JSON

{
"type": "Script",
"span": {
"start": 77,
"end": 508,
"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": 188,
"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": 188,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 176,
"end": 186,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 176,
"end": 179,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 179,
"end": 185,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 181,
"end": 185,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 181,
"end": 185,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 190,
"end": 240,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 200,
"end": 201,
"ctxt": 0
},
"value": "S",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 210,
"end": 211,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 210,
"end": 211,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 212,
"end": 240,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 218,
"end": 232,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 218,
"end": 222,
"ctxt": 0
},
"value": "Foo2",
"optional": false
},
"computed": false,
"optional": true,
"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": 269,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
"start": 261,
"end": 262,
"ctxt": 0
},
"value": 1.0
},
"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": 274,
"end": 324,
"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": 324,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 304,
"end": 316,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
"start": 304,
"end": 305,
"ctxt": 0
},
"value": 2.0
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 306,
"end": 315,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 308,
"end": 315,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 308,
"end": 315,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 326,
"end": 357,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 336,
"end": 338,
"ctxt": 0
},
"value": "T3",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 339,
"end": 357,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 345,
"end": 355,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "StringLiteral",
"span": {
"start": 345,
"end": 348,
"ctxt": 0
},
"value": "1",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"computed": false,
"optional": false,
"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": 413,
"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": 413,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 389,
"end": 405,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "StringLiteral",
"span": {
"start": 389,
"end": 394,
"ctxt": 0
},
"value": "1.0",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"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": 438,
"end": 459,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 442,
"end": 459,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 442,
"end": 443,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 443,
"end": 459,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 445,
"end": 459,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 447,
"end": 457,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 447,
"end": 450,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": false,
"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": 486,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 464,
"end": 486,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 464,
"end": 465,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 465,
"end": 486,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 467,
"end": 486,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 469,
"end": 484,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 469,
"end": 473,
"ctxt": 0
},
"value": "Foo2",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 474,
"end": 483,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 476,
"end": 483,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 476,
"end": 483,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 487,
"end": 508,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 491,
"end": 507,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 491,
"end": 492,
"ctxt": 0
},
"value": "r",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ConditionalExpression",
"span": {
"start": 495,
"end": 507,
"ctxt": 0
},
"test": {
"type": "BooleanLiteral",
"span": {
"start": 495,
"end": 499,
"ctxt": 0
},
"value": true
},
"consequent": {
"type": "Identifier",
"span": {
"start": 502,
"end": 503,
"ctxt": 0
},
"value": "a",
"optional": false
},
"alternate": {
"type": "Identifier",
"span": {
"start": 506,
"end": 507,
"ctxt": 0
},
"value": "b",
"optional": false
}
},
"definite": false
}
]
}
],
"interpreter": null
}