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

1189 lines
30 KiB
JSON

{
"type": "Script",
"span": {
"start": 371,
"end": 834,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 371,
"end": 433,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 381,
"end": 385,
"ctxt": 0
},
"value": "Item",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 386,
"end": 433,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 392,
"end": 405,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 392,
"end": 396,
"ctxt": 0
},
"value": "name",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 396,
"end": 404,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 398,
"end": 404,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 410,
"end": 431,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 410,
"end": 421,
"ctxt": 0
},
"value": "description",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 422,
"end": 430,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 424,
"end": 430,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 452,
"end": 455,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"declare": true,
"params": [
{
"type": "Parameter",
"span": {
"start": 456,
"end": 466,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 456,
"end": 466,
"ctxt": 0
},
"value": "item",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 460,
"end": 466,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 462,
"end": 466,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 462,
"end": 466,
"ctxt": 0
},
"value": "Item",
"optional": false
},
"typeParams": null
}
}
}
}
],
"decorators": [],
"span": {
"start": 435,
"end": 476,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 467,
"end": 475,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 469,
"end": 475,
"ctxt": 0
},
"kind": "string"
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 494,
"end": 497,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"declare": true,
"params": [
{
"type": "Parameter",
"span": {
"start": 498,
"end": 507,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 498,
"end": 507,
"ctxt": 0
},
"value": "item",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 502,
"end": 507,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 504,
"end": 507,
"ctxt": 0
},
"kind": "any"
}
}
}
}
],
"decorators": [],
"span": {
"start": 477,
"end": 517,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 508,
"end": 516,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 510,
"end": 516,
"ctxt": 0
},
"kind": "number"
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 519,
"end": 553,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 523,
"end": 552,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 523,
"end": 524,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 527,
"end": 552,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 527,
"end": 530,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ObjectExpression",
"span": {
"start": 531,
"end": 551,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 533,
"end": 537,
"ctxt": 0
},
"value": "name",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 539,
"end": 549,
"ctxt": 0
},
"value": "Sprocket",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
]
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 554,
"end": 568,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 558,
"end": 567,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 558,
"end": 559,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 559,
"end": 567,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 561,
"end": 567,
"ctxt": 0
},
"kind": "string"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 570,
"end": 632,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 574,
"end": 631,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 574,
"end": 575,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 578,
"end": 631,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 578,
"end": 581,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ObjectExpression",
"span": {
"start": 582,
"end": 630,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 584,
"end": 588,
"ctxt": 0
},
"value": "name",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 590,
"end": 600,
"ctxt": 0
},
"value": "Sprocket",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 602,
"end": 613,
"ctxt": 0
},
"value": "description",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 615,
"end": 628,
"ctxt": 0
},
"value": "Bumpy wheel",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
]
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 633,
"end": 647,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 637,
"end": 646,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 637,
"end": 638,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 638,
"end": 646,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 640,
"end": 646,
"ctxt": 0
},
"kind": "string"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 649,
"end": 703,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 653,
"end": 702,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 653,
"end": 654,
"ctxt": 0
},
"value": "z",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 657,
"end": 702,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 657,
"end": 660,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ObjectExpression",
"span": {
"start": 661,
"end": 701,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 663,
"end": 667,
"ctxt": 0
},
"value": "name",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 669,
"end": 679,
"ctxt": 0
},
"value": "Sprocket",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 681,
"end": 692,
"ctxt": 0
},
"value": "description",
"optional": false
},
"value": {
"type": "BooleanLiteral",
"span": {
"start": 694,
"end": 699,
"ctxt": 0
},
"value": false
}
}
]
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 704,
"end": 718,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 708,
"end": 717,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 708,
"end": 709,
"ctxt": 0
},
"value": "z",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 709,
"end": 717,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 711,
"end": 717,
"ctxt": 0
},
"kind": "number"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 720,
"end": 743,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 724,
"end": 742,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 724,
"end": 725,
"ctxt": 0
},
"value": "w",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 728,
"end": 742,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 728,
"end": 731,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ObjectExpression",
"span": {
"start": 732,
"end": 741,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 734,
"end": 735,
"ctxt": 0
},
"value": "a",
"optional": false
},
"value": {
"type": "NumericLiteral",
"span": {
"start": 737,
"end": 739,
"ctxt": 0
},
"value": 10.0
}
}
]
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 744,
"end": 758,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 748,
"end": 757,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 748,
"end": 749,
"ctxt": 0
},
"value": "w",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 749,
"end": 757,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 751,
"end": 757,
"ctxt": 0
},
"kind": "number"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 777,
"end": 780,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"declare": true,
"params": [
{
"type": "Parameter",
"span": {
"start": 784,
"end": 800,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 784,
"end": 800,
"ctxt": 0
},
"value": "param",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 789,
"end": 800,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 791,
"end": 800,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 793,
"end": 798,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 793,
"end": 794,
"ctxt": 0
},
"value": "x",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 795,
"end": 798,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 797,
"end": 798,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 797,
"end": 798,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
}
}
],
"decorators": [],
"span": {
"start": 760,
"end": 805,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 780,
"end": 783,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 781,
"end": 782,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 781,
"end": 782,
"ctxt": 0
},
"value": "T",
"optional": false
},
"constraint": null,
"default": null
}
]
},
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 801,
"end": 804,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 803,
"end": 804,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 803,
"end": 804,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 807,
"end": 823,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 811,
"end": 822,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 811,
"end": 812,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 815,
"end": 822,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 815,
"end": 818,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ObjectExpression",
"span": {
"start": 819,
"end": 821,
"ctxt": 0
},
"properties": []
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 824,
"end": 834,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 828,
"end": 833,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 828,
"end": 829,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 829,
"end": 833,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 831,
"end": 833,
"ctxt": 0
},
"members": []
}
}
},
"init": null,
"definite": false
}
]
}
],
"interpreter": null
}