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

444 lines
12 KiB
JSON

{
"type": "Script",
"span": {
"start": 146,
"end": 275,
"ctxt": 0
},
"body": [
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 155,
"end": 156,
"ctxt": 0
},
"value": "f",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 160,
"end": 164,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 160,
"end": 164,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 161,
"end": 164,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 163,
"end": 164,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 163,
"end": 164,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
],
"decorators": [],
"span": {
"start": 146,
"end": 214,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 166,
"end": 214,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 172,
"end": 198,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 176,
"end": 197,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 176,
"end": 177,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 177,
"end": 193,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 179,
"end": 193,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 181,
"end": 191,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 181,
"end": 182,
"ctxt": 0
},
"value": "s",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 183,
"end": 191,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 185,
"end": 191,
"ctxt": 0
},
"kind": "number"
}
},
"typeParams": null
}
]
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 196,
"end": 197,
"ctxt": 0
},
"value": "a",
"optional": false
},
"definite": false
}
]
},
{
"type": "ReturnStatement",
"span": {
"start": 203,
"end": 212,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 210,
"end": 211,
"ctxt": 0
},
"value": "b",
"optional": false
}
}
]
},
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 156,
"end": 159,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 157,
"end": 158,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 157,
"end": 158,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": null,
"default": null
}
]
},
"returnType": null
},
{
"type": "VariableDeclaration",
"span": {
"start": 216,
"end": 247,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 220,
"end": 246,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 220,
"end": 221,
"ctxt": 0
},
"value": "r",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 224,
"end": 246,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 224,
"end": 225,
"ctxt": 0
},
"value": "f",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ObjectExpression",
"span": {
"start": 226,
"end": 245,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 228,
"end": 229,
"ctxt": 0
},
"value": "s",
"optional": false
},
"value": {
"type": "NewExpression",
"span": {
"start": 231,
"end": 243,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 235,
"end": 241,
"ctxt": 0
},
"value": "Object",
"optional": false
},
"arguments": [],
"typeArguments": null
}
}
]
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 254,
"end": 275,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 254,
"end": 274,
"ctxt": 0
},
"operator": "&&",
"left": {
"type": "MemberExpression",
"span": {
"start": 254,
"end": 257,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 254,
"end": 255,
"ctxt": 0
},
"value": "r",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 256,
"end": 257,
"ctxt": 0
},
"value": "s",
"optional": false
}
},
"right": {
"type": "CallExpression",
"span": {
"start": 261,
"end": 274,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 261,
"end": 272,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 261,
"end": 264,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 261,
"end": 262,
"ctxt": 0
},
"value": "r",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 263,
"end": 264,
"ctxt": 0
},
"value": "s",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 265,
"end": 272,
"ctxt": 0
},
"value": "toFixed",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
}
}
],
"interpreter": null
}