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

1165 lines
34 KiB
JSON

{
"type": "Script",
"span": {
"start": 19,
"end": 666,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 19,
"end": 67,
"ctxt": 0
},
"kind": "let",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 31,
"end": 66,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 31,
"end": 49,
"ctxt": 0
},
"value": "optionalProperties",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 49,
"end": 66,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 51,
"end": 66,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 53,
"end": 64,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 53,
"end": 55,
"ctxt": 0
},
"value": "k1",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 56,
"end": 64,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 58,
"end": 64,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 68,
"end": 128,
"ctxt": 0
},
"kind": "let",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 80,
"end": 127,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 80,
"end": 99,
"ctxt": 0
},
"value": "undefinedProperties",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 99,
"end": 127,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 101,
"end": 127,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 103,
"end": 125,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 103,
"end": 105,
"ctxt": 0
},
"value": "k1",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 105,
"end": 125,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 107,
"end": 125,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 107,
"end": 113,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 116,
"end": 125,
"ctxt": 0
},
"kind": "undefined"
}
]
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 130,
"end": 186,
"ctxt": 0
},
"kind": "let",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 142,
"end": 185,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 142,
"end": 158,
"ctxt": 0
},
"value": "stringDictionary",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 158,
"end": 185,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 160,
"end": 185,
"ctxt": 0
},
"members": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 163,
"end": 174,
"ctxt": 0
},
"value": "key",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 166,
"end": 174,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 168,
"end": 174,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 175,
"end": 183,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 177,
"end": 183,
"ctxt": 0
},
"kind": "string"
}
},
"readonly": false,
"static": false,
"span": {
"start": 162,
"end": 183,
"ctxt": 0
}
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 187,
"end": 225,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 187,
"end": 224,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 187,
"end": 203,
"ctxt": 0
},
"value": "stringDictionary",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 206,
"end": 224,
"ctxt": 0
},
"value": "optionalProperties",
"optional": false
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 233,
"end": 272,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 233,
"end": 271,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 233,
"end": 249,
"ctxt": 0
},
"value": "stringDictionary",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 252,
"end": 271,
"ctxt": 0
},
"value": "undefinedProperties",
"optional": false
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 283,
"end": 336,
"ctxt": 0
},
"kind": "let",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 295,
"end": 335,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 295,
"end": 308,
"ctxt": 0
},
"value": "probablyArray",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 308,
"end": 335,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 310,
"end": 335,
"ctxt": 0
},
"members": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 313,
"end": 324,
"ctxt": 0
},
"value": "key",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 316,
"end": 324,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 318,
"end": 324,
"ctxt": 0
},
"kind": "number"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 325,
"end": 333,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 327,
"end": 333,
"ctxt": 0
},
"kind": "string"
}
},
"readonly": false,
"static": false,
"span": {
"start": 312,
"end": 333,
"ctxt": 0
}
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 337,
"end": 383,
"ctxt": 0
},
"kind": "let",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 349,
"end": 382,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 349,
"end": 366,
"ctxt": 0
},
"value": "numberLiteralKeys",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 366,
"end": 382,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 368,
"end": 382,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 370,
"end": 380,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "NumericLiteral",
"span": {
"start": 370,
"end": 371,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 372,
"end": 380,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 374,
"end": 380,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 384,
"end": 418,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 384,
"end": 417,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 384,
"end": 397,
"ctxt": 0
},
"value": "probablyArray",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 400,
"end": 417,
"ctxt": 0
},
"value": "numberLiteralKeys",
"optional": false
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 430,
"end": 480,
"ctxt": 0
},
"kind": "let",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 442,
"end": 479,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 442,
"end": 459,
"ctxt": 0
},
"value": "optionalUndefined",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 459,
"end": 479,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 461,
"end": 479,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 463,
"end": 477,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 463,
"end": 465,
"ctxt": 0
},
"value": "k1",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 466,
"end": 477,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 468,
"end": 477,
"ctxt": 0
},
"kind": "undefined"
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 481,
"end": 537,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 485,
"end": 536,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 485,
"end": 489,
"ctxt": 0
},
"value": "dict",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 489,
"end": 516,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 491,
"end": 516,
"ctxt": 0
},
"members": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 494,
"end": 505,
"ctxt": 0
},
"value": "key",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 497,
"end": 505,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 499,
"end": 505,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 506,
"end": 514,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 508,
"end": 514,
"ctxt": 0
},
"kind": "string"
}
},
"readonly": false,
"static": false,
"span": {
"start": 493,
"end": 514,
"ctxt": 0
}
}
]
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 519,
"end": 536,
"ctxt": 0
},
"value": "optionalUndefined",
"optional": false
},
"definite": false
}
]
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 557,
"end": 558,
"ctxt": 0
},
"value": "f",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 548,
"end": 666,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 564,
"end": 666,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 567,
"end": 605,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 571,
"end": 604,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 571,
"end": 579,
"ctxt": 0
},
"value": "optional",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 579,
"end": 591,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 581,
"end": 591,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 583,
"end": 589,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 583,
"end": 585,
"ctxt": 0
},
"value": "k1",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 586,
"end": 589,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 588,
"end": 589,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 588,
"end": 589,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
},
"typeParams": null
}
]
}
}
},
"init": {
"type": "TsNonNullExpression",
"span": {
"start": 594,
"end": 604,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 594,
"end": 603,
"ctxt": 0
},
"value": "undefined",
"optional": false
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 607,
"end": 658,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 611,
"end": 657,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 611,
"end": 615,
"ctxt": 0
},
"value": "dict",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 615,
"end": 646,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 617,
"end": 646,
"ctxt": 0
},
"members": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 620,
"end": 631,
"ctxt": 0
},
"value": "key",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 623,
"end": 631,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 625,
"end": 631,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 632,
"end": 644,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 634,
"end": 644,
"ctxt": 0
},
"types": [
{
"type": "TsTypeReference",
"span": {
"start": 634,
"end": 635,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 634,
"end": 635,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
},
{
"type": "TsKeywordType",
"span": {
"start": 638,
"end": 644,
"ctxt": 0
},
"kind": "number"
}
]
}
},
"readonly": false,
"static": false,
"span": {
"start": 619,
"end": 644,
"ctxt": 0
}
}
]
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 649,
"end": 657,
"ctxt": 0
},
"value": "optional",
"optional": false
},
"definite": false
}
]
}
]
},
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 558,
"end": 561,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 559,
"end": 560,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 559,
"end": 560,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": null,
"default": null
}
]
},
"returnType": null
}
],
"interpreter": null
}