swc/crates/swc_ecma_parser/tests/tsc/subtypingWithObjectMembersOptionality3.json
2022-02-04 17:08:38 +09:00

1005 lines
24 KiB
JSON

{
"type": "Script",
"span": {
"start": 78,
"end": 538,
"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": 111,
"end": 158,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 121,
"end": 128,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 137,
"end": 141,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 137,
"end": 141,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 142,
"end": 158,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 144,
"end": 156,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 144,
"end": 147,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 147,
"end": 155,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 149,
"end": 155,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 162,
"end": 195,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 172,
"end": 173,
"ctxt": 0
},
"value": "T",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 174,
"end": 195,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 181,
"end": 192,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 181,
"end": 184,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 185,
"end": 191,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 187,
"end": 191,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 187,
"end": 191,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 199,
"end": 250,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 209,
"end": 210,
"ctxt": 0
},
"value": "S",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 219,
"end": 220,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 219,
"end": 220,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 221,
"end": 250,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 228,
"end": 241,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 228,
"end": 232,
"ctxt": 0
},
"value": "Foo2",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 232,
"end": 241,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 234,
"end": 241,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 234,
"end": 241,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 254,
"end": 286,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 264,
"end": 266,
"ctxt": 0
},
"value": "T2",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 267,
"end": 286,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 274,
"end": 283,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
"start": 274,
"end": 275,
"ctxt": 0
},
"value": 1.0
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 276,
"end": 282,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 278,
"end": 282,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 278,
"end": 282,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 290,
"end": 341,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 300,
"end": 302,
"ctxt": 0
},
"value": "S2",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 311,
"end": 313,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 311,
"end": 313,
"ctxt": 0
},
"value": "T2",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 314,
"end": 341,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 321,
"end": 332,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
"start": 321,
"end": 322,
"ctxt": 0
},
"value": 2.0
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 322,
"end": 331,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 324,
"end": 331,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 324,
"end": 331,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 345,
"end": 379,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 355,
"end": 357,
"ctxt": 0
},
"value": "T3",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 358,
"end": 379,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 365,
"end": 376,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "StringLiteral",
"span": {
"start": 365,
"end": 368,
"ctxt": 0
},
"value": "1",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 369,
"end": 375,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 371,
"end": 375,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 371,
"end": 375,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 383,
"end": 438,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 393,
"end": 395,
"ctxt": 0
},
"value": "S3",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 404,
"end": 406,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 404,
"end": 406,
"ctxt": 0
},
"value": "T3",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 407,
"end": 438,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 414,
"end": 429,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "StringLiteral",
"span": {
"start": 414,
"end": 419,
"ctxt": 0
},
"value": "1.0",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 419,
"end": 428,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 421,
"end": 428,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 421,
"end": 428,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 466,
"end": 488,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 470,
"end": 488,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 470,
"end": 471,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 471,
"end": 488,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 473,
"end": 488,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 475,
"end": 486,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 475,
"end": 478,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 479,
"end": 485,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 481,
"end": 485,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 481,
"end": 485,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 490,
"end": 515,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 494,
"end": 515,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 494,
"end": 495,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 495,
"end": 515,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 497,
"end": 515,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 499,
"end": 513,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 499,
"end": 503,
"ctxt": 0
},
"value": "Foo2",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 503,
"end": 512,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 505,
"end": 512,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 505,
"end": 512,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 517,
"end": 538,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 521,
"end": 537,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 521,
"end": 522,
"ctxt": 0
},
"value": "r",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ConditionalExpression",
"span": {
"start": 525,
"end": 537,
"ctxt": 0
},
"test": {
"type": "BooleanLiteral",
"span": {
"start": 525,
"end": 529,
"ctxt": 0
},
"value": true
},
"consequent": {
"type": "Identifier",
"span": {
"start": 532,
"end": 533,
"ctxt": 0
},
"value": "a",
"optional": false
},
"alternate": {
"type": "Identifier",
"span": {
"start": 536,
"end": 537,
"ctxt": 0
},
"value": "b",
"optional": false
}
},
"definite": false
}
]
}
],
"interpreter": null
}