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

1090 lines
28 KiB
JSON

{
"type": "Script",
"span": {
"start": 24,
"end": 394,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 24,
"end": 50,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 28,
"end": 49,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 28,
"end": 29,
"ctxt": 0
},
"value": "o",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "ObjectExpression",
"span": {
"start": 32,
"end": 49,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 34,
"end": 35,
"ctxt": 0
},
"value": "a",
"optional": false
},
"value": {
"type": "NumericLiteral",
"span": {
"start": 37,
"end": 38,
"ctxt": 0
},
"value": 1.0
}
},
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 40,
"end": 41,
"ctxt": 0
},
"value": "b",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 43,
"end": 47,
"ctxt": 0
},
"value": "no",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
]
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 51,
"end": 80,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 55,
"end": 79,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 55,
"end": 75,
"ctxt": 0
},
"properties": [
{
"type": "RestElement",
"span": {
"start": 57,
"end": 70,
"ctxt": 0
},
"rest": {
"start": 57,
"end": 60,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 60,
"end": 70,
"ctxt": 0
},
"value": "mustBeLast",
"optional": false,
"typeAnnotation": null
},
"typeAnnotation": null
},
{
"type": "AssignmentPatternProperty",
"span": {
"start": 72,
"end": 73,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 72,
"end": 73,
"ctxt": 0
},
"value": "a",
"optional": false
},
"value": null
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "Identifier",
"span": {
"start": 78,
"end": 79,
"ctxt": 0
},
"value": "o",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 82,
"end": 96,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 86,
"end": 95,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 86,
"end": 87,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 87,
"end": 95,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 89,
"end": 95,
"ctxt": 0
},
"kind": "string"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 97,
"end": 130,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 101,
"end": 129,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 101,
"end": 114,
"ctxt": 0
},
"value": "notAssignable",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 114,
"end": 129,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 116,
"end": 129,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 118,
"end": 127,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 118,
"end": 119,
"ctxt": 0
},
"value": "a",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 119,
"end": 127,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 121,
"end": 127,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 131,
"end": 161,
"ctxt": 0
},
"expression": {
"type": "ParenthesisExpression",
"span": {
"start": 131,
"end": 160,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 132,
"end": 159,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "ObjectPattern",
"span": {
"start": 132,
"end": 155,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 134,
"end": 135,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 134,
"end": 135,
"ctxt": 0
},
"value": "b",
"optional": false
},
"value": null
},
{
"type": "RestElement",
"span": {
"start": 137,
"end": 153,
"ctxt": 0
},
"rest": {
"start": 137,
"end": 140,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 140,
"end": 153,
"ctxt": 0
},
"value": "notAssignable",
"optional": false,
"typeAnnotation": null
},
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 158,
"end": 159,
"ctxt": 0
},
"value": "o",
"optional": false
}
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 173,
"end": 188,
"ctxt": 0
},
"value": "stillMustBeLast",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 189,
"end": 235,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "ObjectPattern",
"span": {
"start": 189,
"end": 235,
"ctxt": 0
},
"properties": [
{
"type": "RestElement",
"span": {
"start": 191,
"end": 204,
"ctxt": 0
},
"rest": {
"start": 191,
"end": 194,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 194,
"end": 204,
"ctxt": 0
},
"value": "mustBeLast",
"optional": false,
"typeAnnotation": null
},
"typeAnnotation": null
},
{
"type": "AssignmentPatternProperty",
"span": {
"start": 206,
"end": 207,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 206,
"end": 207,
"ctxt": 0
},
"value": "a",
"optional": false
},
"value": null
}
],
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 209,
"end": 235,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 211,
"end": 235,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 213,
"end": 223,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 213,
"end": 214,
"ctxt": 0
},
"value": "a",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 214,
"end": 222,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 216,
"end": 222,
"ctxt": 0
},
"kind": "number"
}
},
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 224,
"end": 233,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 224,
"end": 225,
"ctxt": 0
},
"value": "b",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 225,
"end": 233,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 227,
"end": 233,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
}
}
}
],
"decorators": [],
"span": {
"start": 164,
"end": 246,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 243,
"end": 246,
"ctxt": 0
},
"stmts": []
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 236,
"end": 242,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 238,
"end": 242,
"ctxt": 0
},
"kind": "void"
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 256,
"end": 263,
"ctxt": 0
},
"value": "generic",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 284,
"end": 288,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 284,
"end": 288,
"ctxt": 0
},
"value": "t",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 285,
"end": 288,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 287,
"end": 288,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 287,
"end": 288,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
],
"decorators": [],
"span": {
"start": 247,
"end": 338,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 290,
"end": 338,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 296,
"end": 319,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 300,
"end": 318,
"ctxt": 0
},
"id": {
"type": "ObjectPattern",
"span": {
"start": 300,
"end": 314,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 302,
"end": 303,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 302,
"end": 303,
"ctxt": 0
},
"value": "x",
"optional": false
},
"value": null
},
{
"type": "RestElement",
"span": {
"start": 305,
"end": 312,
"ctxt": 0
},
"rest": {
"start": 305,
"end": 308,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 308,
"end": 312,
"ctxt": 0
},
"value": "rest",
"optional": false,
"typeAnnotation": null
},
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "Identifier",
"span": {
"start": 317,
"end": 318,
"ctxt": 0
},
"value": "t",
"optional": false
},
"definite": false
}
]
},
{
"type": "ReturnStatement",
"span": {
"start": 324,
"end": 336,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 331,
"end": 335,
"ctxt": 0
},
"value": "rest",
"optional": false
}
}
]
},
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 263,
"end": 283,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 264,
"end": 282,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 264,
"end": 265,
"ctxt": 0
},
"value": "T",
"optional": false
},
"constraint": {
"type": "TsTypeLiteral",
"span": {
"start": 274,
"end": 282,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 276,
"end": 278,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 276,
"end": 277,
"ctxt": 0
},
"value": "x",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": null,
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 279,
"end": 280,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 279,
"end": 280,
"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": 340,
"end": 363,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 344,
"end": 363,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 344,
"end": 348,
"ctxt": 0
},
"value": "rest",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 348,
"end": 363,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 350,
"end": 363,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 352,
"end": 361,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 352,
"end": 353,
"ctxt": 0
},
"value": "b",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 353,
"end": 361,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 355,
"end": 361,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 364,
"end": 394,
"ctxt": 0
},
"expression": {
"type": "ParenthesisExpression",
"span": {
"start": 364,
"end": 393,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 365,
"end": 392,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "ObjectPattern",
"span": {
"start": 365,
"end": 388,
"ctxt": 0
},
"properties": [
{
"type": "AssignmentPatternProperty",
"span": {
"start": 366,
"end": 367,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 366,
"end": 367,
"ctxt": 0
},
"value": "a",
"optional": false
},
"value": null
},
{
"type": "RestElement",
"span": {
"start": 369,
"end": 387,
"ctxt": 0
},
"rest": {
"start": 369,
"end": 372,
"ctxt": 0
},
"argument": {
"type": "Invalid",
"span": {
"start": 372,
"end": 387,
"ctxt": 0
}
},
"typeAnnotation": null
}
],
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 391,
"end": 392,
"ctxt": 0
},
"value": "o",
"optional": false
}
}
}
}
],
"interpreter": null
}