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

1090 lines
28 KiB
JSON

{
"type": "Script",
"span": {
"start": 25,
"end": 395,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 25,
"end": 51,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 29,
"end": 50,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 29,
"end": 30,
"ctxt": 0
},
"value": "o",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ObjectExpression",
"span": {
"start": 33,
"end": 50,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 35,
"end": 36,
"ctxt": 0
},
"value": "a",
"optional": false
},
"value": {
"type": "NumericLiteral",
"span": {
"start": 38,
"end": 39,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
},
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 41,
"end": 42,
"ctxt": 0
},
"value": "b",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 44,
"end": 48,
"ctxt": 0
},
"value": "no",
"raw": "'no'"
}
}
]
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 52,
"end": 81,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 56,
"end": 80,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 56,
"end": 76,
"ctxt": 0
},
"properties": [
{
"type": "RestElement",
"span": {
"start": 58,
"end": 71,
"ctxt": 0
},
"rest": {
"start": 58,
"end": 61,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 61,
"end": 71,
"ctxt": 0
},
"value": "mustBeLast",
"optional": false,
"typeAnnotation": null
},
"typeAnnotation": null
},
{
"type": "AssignmentPatternProperty",
"span": {
"start": 73,
"end": 74,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 73,
"end": 74,
"ctxt": 0
},
"value": "a",
"optional": false
},
"value": null
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "Identifier",
"span": {
"start": 79,
"end": 80,
"ctxt": 0
},
"value": "o",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 83,
"end": 97,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 87,
"end": 96,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 87,
"end": 88,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 88,
"end": 96,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 90,
"end": 96,
"ctxt": 0
},
"kind": "string"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 98,
"end": 131,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 102,
"end": 130,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 102,
"end": 115,
"ctxt": 0
},
"value": "notAssignable",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 115,
"end": 130,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 117,
"end": 130,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 119,
"end": 128,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 119,
"end": 120,
"ctxt": 0
},
"value": "a",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 120,
"end": 128,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 122,
"end": 128,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 132,
"end": 162,
"ctxt": 0
},
"expression": {
"type": "ParenthesisExpression",
"span": {
"start": 132,
"end": 161,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 133,
"end": 160,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "ObjectPattern",
"span": {
"start": 133,
"end": 156,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 135,
"end": 136,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 135,
"end": 136,
"ctxt": 0
},
"value": "b",
"optional": false
},
"value": null
},
{
"type": "RestElement",
"span": {
"start": 138,
"end": 154,
"ctxt": 0
},
"rest": {
"start": 138,
"end": 141,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 141,
"end": 154,
"ctxt": 0
},
"value": "notAssignable",
"optional": false,
"typeAnnotation": null
},
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 159,
"end": 160,
"ctxt": 0
},
"value": "o",
"optional": false
}
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 174,
"end": 189,
"ctxt": 0
},
"value": "stillMustBeLast",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 190,
"end": 236,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "ObjectPattern",
"span": {
"start": 190,
"end": 236,
"ctxt": 0
},
"properties": [
{
"type": "RestElement",
"span": {
"start": 192,
"end": 205,
"ctxt": 0
},
"rest": {
"start": 192,
"end": 195,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 195,
"end": 205,
"ctxt": 0
},
"value": "mustBeLast",
"optional": false,
"typeAnnotation": null
},
"typeAnnotation": null
},
{
"type": "AssignmentPatternProperty",
"span": {
"start": 207,
"end": 208,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 207,
"end": 208,
"ctxt": 0
},
"value": "a",
"optional": false
},
"value": null
}
],
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 210,
"end": 236,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 212,
"end": 236,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 214,
"end": 224,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 214,
"end": 215,
"ctxt": 0
},
"value": "a",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 215,
"end": 223,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 217,
"end": 223,
"ctxt": 0
},
"kind": "number"
}
},
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 225,
"end": 234,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 225,
"end": 226,
"ctxt": 0
},
"value": "b",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 226,
"end": 234,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 228,
"end": 234,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
}
}
}
],
"decorators": [],
"span": {
"start": 165,
"end": 247,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 244,
"end": 247,
"ctxt": 0
},
"stmts": []
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 237,
"end": 243,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 239,
"end": 243,
"ctxt": 0
},
"kind": "void"
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 257,
"end": 264,
"ctxt": 0
},
"value": "generic",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 285,
"end": 289,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 285,
"end": 289,
"ctxt": 0
},
"value": "t",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 286,
"end": 289,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 288,
"end": 289,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 288,
"end": 289,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
],
"decorators": [],
"span": {
"start": 248,
"end": 339,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 291,
"end": 339,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 297,
"end": 320,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 301,
"end": 319,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 301,
"end": 315,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 303,
"end": 304,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 303,
"end": 304,
"ctxt": 0
},
"value": "x",
"optional": false
},
"value": null
},
{
"type": "RestElement",
"span": {
"start": 306,
"end": 313,
"ctxt": 0
},
"rest": {
"start": 306,
"end": 309,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 309,
"end": 313,
"ctxt": 0
},
"value": "rest",
"optional": false,
"typeAnnotation": null
},
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "Identifier",
"span": {
"start": 318,
"end": 319,
"ctxt": 0
},
"value": "t",
"optional": false
},
"definite": false
}
]
},
{
"type": "ReturnStatement",
"span": {
"start": 325,
"end": 337,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 332,
"end": 336,
"ctxt": 0
},
"value": "rest",
"optional": false
}
}
]
},
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 264,
"end": 284,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 265,
"end": 283,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 265,
"end": 266,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": {
"type": "TsTypeLiteral",
"span": {
"start": 275,
"end": 283,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 277,
"end": 279,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 277,
"end": 278,
"ctxt": 0
},
"value": "x",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": null,
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 280,
"end": 281,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 280,
"end": 281,
"ctxt": 0
},
"value": "y",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": null,
"typeParams": null
}
]
},
"default": null
}
]
},
"returnType": null
},
{
"type": "VariableDeclaration",
"span": {
"start": 341,
"end": 364,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 345,
"end": 364,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 345,
"end": 349,
"ctxt": 0
},
"value": "rest",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 349,
"end": 364,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 351,
"end": 364,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 353,
"end": 362,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 353,
"end": 354,
"ctxt": 0
},
"value": "b",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 354,
"end": 362,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 356,
"end": 362,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 365,
"end": 395,
"ctxt": 0
},
"expression": {
"type": "ParenthesisExpression",
"span": {
"start": 365,
"end": 394,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 366,
"end": 393,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "ObjectPattern",
"span": {
"start": 366,
"end": 389,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 367,
"end": 368,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 367,
"end": 368,
"ctxt": 0
},
"value": "a",
"optional": false
},
"value": null
},
{
"type": "RestElement",
"span": {
"start": 370,
"end": 388,
"ctxt": 0
},
"rest": {
"start": 370,
"end": 373,
"ctxt": 0
},
"argument": {
"type": "Invalid",
"span": {
"start": 373,
"end": 388,
"ctxt": 0
}
},
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 392,
"end": 393,
"ctxt": 0
},
"value": "o",
"optional": false
}
}
}
}
],
"interpreter": null
}