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

1161 lines
33 KiB
JSON

{
"type": "Script",
"span": {
"start": 18,
"end": 665,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 18,
"end": 66,
"ctxt": 0
},
"kind": "let",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 30,
"end": 65,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 30,
"end": 48,
"ctxt": 0
},
"value": "optionalProperties",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 48,
"end": 65,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 50,
"end": 65,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 52,
"end": 63,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 52,
"end": 54,
"ctxt": 0
},
"value": "k1",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 55,
"end": 63,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 57,
"end": 63,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 67,
"end": 127,
"ctxt": 0
},
"kind": "let",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 79,
"end": 126,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 79,
"end": 98,
"ctxt": 0
},
"value": "undefinedProperties",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 98,
"end": 126,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 100,
"end": 126,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 102,
"end": 124,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 102,
"end": 104,
"ctxt": 0
},
"value": "k1",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 104,
"end": 124,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 106,
"end": 124,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 106,
"end": 112,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 115,
"end": 124,
"ctxt": 0
},
"kind": "undefined"
}
]
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 129,
"end": 185,
"ctxt": 0
},
"kind": "let",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 141,
"end": 184,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 141,
"end": 157,
"ctxt": 0
},
"value": "stringDictionary",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 157,
"end": 184,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 159,
"end": 184,
"ctxt": 0
},
"members": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 162,
"end": 173,
"ctxt": 0
},
"value": "key",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 165,
"end": 173,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 167,
"end": 173,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 174,
"end": 182,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 176,
"end": 182,
"ctxt": 0
},
"kind": "string"
}
},
"readonly": false,
"static": false,
"span": {
"start": 161,
"end": 182,
"ctxt": 0
}
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 186,
"end": 224,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 186,
"end": 223,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 186,
"end": 202,
"ctxt": 0
},
"value": "stringDictionary",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 205,
"end": 223,
"ctxt": 0
},
"value": "optionalProperties",
"optional": false
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 232,
"end": 271,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 232,
"end": 270,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 232,
"end": 248,
"ctxt": 0
},
"value": "stringDictionary",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 251,
"end": 270,
"ctxt": 0
},
"value": "undefinedProperties",
"optional": false
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 282,
"end": 335,
"ctxt": 0
},
"kind": "let",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 294,
"end": 334,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 294,
"end": 307,
"ctxt": 0
},
"value": "probablyArray",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 307,
"end": 334,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 309,
"end": 334,
"ctxt": 0
},
"members": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 312,
"end": 323,
"ctxt": 0
},
"value": "key",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 315,
"end": 323,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 317,
"end": 323,
"ctxt": 0
},
"kind": "number"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 324,
"end": 332,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 326,
"end": 332,
"ctxt": 0
},
"kind": "string"
}
},
"readonly": false,
"static": false,
"span": {
"start": 311,
"end": 332,
"ctxt": 0
}
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 336,
"end": 382,
"ctxt": 0
},
"kind": "let",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 348,
"end": 381,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 348,
"end": 365,
"ctxt": 0
},
"value": "numberLiteralKeys",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 365,
"end": 381,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 367,
"end": 381,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 369,
"end": 379,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
"start": 369,
"end": 370,
"ctxt": 0
},
"value": 1.0
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 371,
"end": 379,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 373,
"end": 379,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 383,
"end": 417,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 383,
"end": 416,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 383,
"end": 396,
"ctxt": 0
},
"value": "probablyArray",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 399,
"end": 416,
"ctxt": 0
},
"value": "numberLiteralKeys",
"optional": false
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 429,
"end": 479,
"ctxt": 0
},
"kind": "let",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 441,
"end": 478,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 441,
"end": 458,
"ctxt": 0
},
"value": "optionalUndefined",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 458,
"end": 478,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 460,
"end": 478,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 462,
"end": 476,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 462,
"end": 464,
"ctxt": 0
},
"value": "k1",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 465,
"end": 476,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 467,
"end": 476,
"ctxt": 0
},
"kind": "undefined"
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 480,
"end": 536,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 484,
"end": 535,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 484,
"end": 488,
"ctxt": 0
},
"value": "dict",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 488,
"end": 515,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 490,
"end": 515,
"ctxt": 0
},
"members": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 493,
"end": 504,
"ctxt": 0
},
"value": "key",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 496,
"end": 504,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 498,
"end": 504,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 505,
"end": 513,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 507,
"end": 513,
"ctxt": 0
},
"kind": "string"
}
},
"readonly": false,
"static": false,
"span": {
"start": 492,
"end": 513,
"ctxt": 0
}
}
]
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 518,
"end": 535,
"ctxt": 0
},
"value": "optionalUndefined",
"optional": false
},
"definite": false
}
]
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 556,
"end": 557,
"ctxt": 0
},
"value": "f",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 547,
"end": 665,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 563,
"end": 665,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 566,
"end": 604,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 570,
"end": 603,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 570,
"end": 578,
"ctxt": 0
},
"value": "optional",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 578,
"end": 590,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 580,
"end": 590,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 582,
"end": 588,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 582,
"end": 584,
"ctxt": 0
},
"value": "k1",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 585,
"end": 588,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 587,
"end": 588,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 587,
"end": 588,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
},
"init": {
"type": "TsNonNullExpression",
"span": {
"start": 593,
"end": 603,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 593,
"end": 602,
"ctxt": 0
},
"value": "undefined",
"optional": false
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 606,
"end": 657,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 610,
"end": 656,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 610,
"end": 614,
"ctxt": 0
},
"value": "dict",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 614,
"end": 645,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 616,
"end": 645,
"ctxt": 0
},
"members": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 619,
"end": 630,
"ctxt": 0
},
"value": "key",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 622,
"end": 630,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 624,
"end": 630,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 631,
"end": 643,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 633,
"end": 643,
"ctxt": 0
},
"types": [
{
"type": "TsTypeReference",
"span": {
"start": 633,
"end": 634,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 633,
"end": 634,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
},
{
"type": "TsKeywordType",
"span": {
"start": 637,
"end": 643,
"ctxt": 0
},
"kind": "number"
}
]
}
},
"readonly": false,
"static": false,
"span": {
"start": 618,
"end": 643,
"ctxt": 0
}
}
]
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 648,
"end": 656,
"ctxt": 0
},
"value": "optional",
"optional": false
},
"definite": false
}
]
}
]
},
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 557,
"end": 560,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 558,
"end": 559,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 558,
"end": 559,
"ctxt": 0
},
"value": "T",
"optional": false
},
"constraint": null,
"default": null
}
]
},
"returnType": null
}
],
"interpreter": null
}