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

441 lines
11 KiB
JSON

{
"type": "Script",
"span": {
"start": 145,
"end": 274,
"ctxt": 0
},
"body": [
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 154,
"end": 155,
"ctxt": 0
},
"value": "f",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 159,
"end": 163,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 159,
"end": 163,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 160,
"end": 163,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 162,
"end": 163,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 162,
"end": 163,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
],
"decorators": [],
"span": {
"start": 145,
"end": 213,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 165,
"end": 213,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 171,
"end": 197,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 175,
"end": 196,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 175,
"end": 176,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 176,
"end": 192,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 178,
"end": 192,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 180,
"end": 190,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 180,
"end": 181,
"ctxt": 0
},
"value": "s",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 182,
"end": 190,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 184,
"end": 190,
"ctxt": 0
},
"kind": "number"
}
},
"typeParams": null
}
]
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 195,
"end": 196,
"ctxt": 0
},
"value": "a",
"optional": false
},
"definite": false
}
]
},
{
"type": "ReturnStatement",
"span": {
"start": 202,
"end": 211,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 209,
"end": 210,
"ctxt": 0
},
"value": "b",
"optional": false
}
}
]
},
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 155,
"end": 158,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 156,
"end": 157,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 156,
"end": 157,
"ctxt": 0
},
"value": "T",
"optional": false
},
"constraint": null,
"default": null
}
]
},
"returnType": null
},
{
"type": "VariableDeclaration",
"span": {
"start": 215,
"end": 246,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 219,
"end": 245,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 219,
"end": 220,
"ctxt": 0
},
"value": "r",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 223,
"end": 245,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 223,
"end": 224,
"ctxt": 0
},
"value": "f",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ObjectExpression",
"span": {
"start": 225,
"end": 244,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 227,
"end": 228,
"ctxt": 0
},
"value": "s",
"optional": false
},
"value": {
"type": "NewExpression",
"span": {
"start": 230,
"end": 242,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 234,
"end": 240,
"ctxt": 0
},
"value": "Object",
"optional": false
},
"arguments": [],
"typeArguments": null
}
}
]
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 253,
"end": 274,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 253,
"end": 273,
"ctxt": 0
},
"operator": "&&",
"left": {
"type": "MemberExpression",
"span": {
"start": 253,
"end": 256,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 253,
"end": 254,
"ctxt": 0
},
"value": "r",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 255,
"end": 256,
"ctxt": 0
},
"value": "s",
"optional": false
}
},
"right": {
"type": "CallExpression",
"span": {
"start": 260,
"end": 273,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 260,
"end": 271,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 260,
"end": 263,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 260,
"end": 261,
"ctxt": 0
},
"value": "r",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 262,
"end": 263,
"ctxt": 0
},
"value": "s",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 264,
"end": 271,
"ctxt": 0
},
"value": "toFixed",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
}
}
],
"interpreter": null
}