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

1177 lines
29 KiB
JSON

{
"type": "Script",
"span": {
"start": 372,
"end": 835,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 372,
"end": 434,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 382,
"end": 386,
"ctxt": 0
},
"value": "Item",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 387,
"end": 434,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 393,
"end": 406,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 393,
"end": 397,
"ctxt": 0
},
"value": "name",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 397,
"end": 405,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 399,
"end": 405,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 411,
"end": 432,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 411,
"end": 422,
"ctxt": 0
},
"value": "description",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 423,
"end": 431,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 425,
"end": 431,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 453,
"end": 456,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"declare": true,
"params": [
{
"type": "Parameter",
"span": {
"start": 457,
"end": 467,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 457,
"end": 467,
"ctxt": 0
},
"value": "item",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 461,
"end": 467,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 463,
"end": 467,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 463,
"end": 467,
"ctxt": 0
},
"value": "Item",
"optional": false
},
"typeParams": null
}
}
}
}
],
"decorators": [],
"span": {
"start": 436,
"end": 477,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 468,
"end": 476,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 470,
"end": 476,
"ctxt": 0
},
"kind": "string"
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 495,
"end": 498,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"declare": true,
"params": [
{
"type": "Parameter",
"span": {
"start": 499,
"end": 508,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 499,
"end": 508,
"ctxt": 0
},
"value": "item",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 503,
"end": 508,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 505,
"end": 508,
"ctxt": 0
},
"kind": "any"
}
}
}
}
],
"decorators": [],
"span": {
"start": 478,
"end": 518,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 509,
"end": 517,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 511,
"end": 517,
"ctxt": 0
},
"kind": "number"
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 520,
"end": 554,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 524,
"end": 553,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 524,
"end": 525,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 528,
"end": 553,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 528,
"end": 531,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ObjectExpression",
"span": {
"start": 532,
"end": 552,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 534,
"end": 538,
"ctxt": 0
},
"value": "name",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 540,
"end": 550,
"ctxt": 0
},
"value": "Sprocket",
"raw": "\"Sprocket\""
}
}
]
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 555,
"end": 569,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 559,
"end": 568,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 559,
"end": 560,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 560,
"end": 568,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 562,
"end": 568,
"ctxt": 0
},
"kind": "string"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 571,
"end": 633,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 575,
"end": 632,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 575,
"end": 576,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 579,
"end": 632,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 579,
"end": 582,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ObjectExpression",
"span": {
"start": 583,
"end": 631,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 585,
"end": 589,
"ctxt": 0
},
"value": "name",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 591,
"end": 601,
"ctxt": 0
},
"value": "Sprocket",
"raw": "\"Sprocket\""
}
},
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 603,
"end": 614,
"ctxt": 0
},
"value": "description",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 616,
"end": 629,
"ctxt": 0
},
"value": "Bumpy wheel",
"raw": "\"Bumpy wheel\""
}
}
]
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 634,
"end": 648,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 638,
"end": 647,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 638,
"end": 639,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 639,
"end": 647,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 641,
"end": 647,
"ctxt": 0
},
"kind": "string"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 650,
"end": 704,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 654,
"end": 703,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 654,
"end": 655,
"ctxt": 0
},
"value": "z",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 658,
"end": 703,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 658,
"end": 661,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ObjectExpression",
"span": {
"start": 662,
"end": 702,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 664,
"end": 668,
"ctxt": 0
},
"value": "name",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 670,
"end": 680,
"ctxt": 0
},
"value": "Sprocket",
"raw": "\"Sprocket\""
}
},
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 682,
"end": 693,
"ctxt": 0
},
"value": "description",
"optional": false
},
"value": {
"type": "BooleanLiteral",
"span": {
"start": 695,
"end": 700,
"ctxt": 0
},
"value": false
}
}
]
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 705,
"end": 719,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 709,
"end": 718,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 709,
"end": 710,
"ctxt": 0
},
"value": "z",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 710,
"end": 718,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 712,
"end": 718,
"ctxt": 0
},
"kind": "number"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 721,
"end": 744,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 725,
"end": 743,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 725,
"end": 726,
"ctxt": 0
},
"value": "w",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 729,
"end": 743,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 729,
"end": 732,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ObjectExpression",
"span": {
"start": 733,
"end": 742,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 735,
"end": 736,
"ctxt": 0
},
"value": "a",
"optional": false
},
"value": {
"type": "NumericLiteral",
"span": {
"start": 738,
"end": 740,
"ctxt": 0
},
"value": 10.0,
"raw": "10"
}
}
]
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 745,
"end": 759,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 749,
"end": 758,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 749,
"end": 750,
"ctxt": 0
},
"value": "w",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 750,
"end": 758,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 752,
"end": 758,
"ctxt": 0
},
"kind": "number"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 778,
"end": 781,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"declare": true,
"params": [
{
"type": "Parameter",
"span": {
"start": 785,
"end": 801,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 785,
"end": 801,
"ctxt": 0
},
"value": "param",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 790,
"end": 801,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 792,
"end": 801,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 794,
"end": 799,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 794,
"end": 795,
"ctxt": 0
},
"value": "x",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 796,
"end": 799,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 798,
"end": 799,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 798,
"end": 799,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
}
}
],
"decorators": [],
"span": {
"start": 761,
"end": 806,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 781,
"end": 784,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 782,
"end": 783,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 782,
"end": 783,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": null,
"default": null
}
]
},
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 802,
"end": 805,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 804,
"end": 805,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 804,
"end": 805,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 808,
"end": 824,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 812,
"end": 823,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 812,
"end": 813,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 816,
"end": 823,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 816,
"end": 819,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ObjectExpression",
"span": {
"start": 820,
"end": 822,
"ctxt": 0
},
"properties": []
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 825,
"end": 835,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 829,
"end": 834,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 829,
"end": 830,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 830,
"end": 834,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 832,
"end": 834,
"ctxt": 0
},
"members": []
}
}
},
"init": null,
"definite": false
}
]
}
],
"interpreter": null
}