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

997 lines
23 KiB
JSON

{
"type": "Script",
"span": {
"start": 1,
"end": 304,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 1,
"end": 25,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 5,
"end": 24,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 5,
"end": 6,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 6,
"end": 24,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeQuery",
"span": {
"start": 8,
"end": 24,
"ctxt": 0
},
"exprName": {
"type": "Identifier",
"span": {
"start": 15,
"end": 24,
"ctxt": 0
},
"value": "undefined",
"optional": false
},
"typeArguments": null
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 27,
"end": 45,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 31,
"end": 44,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 31,
"end": 32,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 32,
"end": 40,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 34,
"end": 40,
"ctxt": 0
},
"kind": "number"
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 43,
"end": 44,
"ctxt": 0
},
"value": "x",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 46,
"end": 65,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 50,
"end": 64,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 50,
"end": 51,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 51,
"end": 60,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 53,
"end": 60,
"ctxt": 0
},
"kind": "boolean"
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 63,
"end": 64,
"ctxt": 0
},
"value": "x",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 66,
"end": 84,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 70,
"end": 83,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 70,
"end": 71,
"ctxt": 0
},
"value": "c",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 71,
"end": 79,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 73,
"end": 79,
"ctxt": 0
},
"kind": "string"
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 82,
"end": 83,
"ctxt": 0
},
"value": "x",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 85,
"end": 101,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 89,
"end": 100,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 89,
"end": 90,
"ctxt": 0
},
"value": "d",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 90,
"end": 96,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 92,
"end": 96,
"ctxt": 0
},
"kind": "void"
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 99,
"end": 100,
"ctxt": 0
},
"value": "x",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 103,
"end": 131,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 107,
"end": 130,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 107,
"end": 108,
"ctxt": 0
},
"value": "e",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 108,
"end": 126,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeQuery",
"span": {
"start": 110,
"end": 126,
"ctxt": 0
},
"exprName": {
"type": "Identifier",
"span": {
"start": 117,
"end": 126,
"ctxt": 0
},
"value": "undefined",
"optional": false
},
"typeArguments": null
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 129,
"end": 130,
"ctxt": 0
},
"value": "x",
"optional": false
},
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 132,
"end": 138,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 132,
"end": 137,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 132,
"end": 133,
"ctxt": 0
},
"value": "e",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 136,
"end": 137,
"ctxt": 0
},
"value": "x",
"optional": false
}
}
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 161,
"end": 162,
"ctxt": 0
},
"value": "C",
"optional": false
},
"declare": false,
"span": {
"start": 155,
"end": 178,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 165,
"end": 176,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 165,
"end": 168,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 168,
"end": 176,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 170,
"end": 176,
"ctxt": 0
},
"kind": "string"
}
},
"isStatic": false,
"decorators": [],
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false,
"readonly": false,
"declare": false,
"definite": false
}
],
"superClass": null,
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "VariableDeclaration",
"span": {
"start": 179,
"end": 188,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 183,
"end": 187,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 183,
"end": 184,
"ctxt": 0
},
"value": "f",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 184,
"end": 187,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 186,
"end": 187,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 186,
"end": 187,
"ctxt": 0
},
"value": "C",
"optional": false
},
"typeParams": null
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 189,
"end": 195,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 189,
"end": 194,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 189,
"end": 190,
"ctxt": 0
},
"value": "f",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 193,
"end": 194,
"ctxt": 0
},
"value": "x",
"optional": false
}
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 197,
"end": 224,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 207,
"end": 208,
"ctxt": 0
},
"value": "I",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 209,
"end": 224,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 211,
"end": 222,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 211,
"end": 214,
"ctxt": 0
},
"value": "foo",
"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": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 225,
"end": 234,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 229,
"end": 233,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 229,
"end": 230,
"ctxt": 0
},
"value": "g",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 230,
"end": 233,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 232,
"end": 233,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 232,
"end": 233,
"ctxt": 0
},
"value": "I",
"optional": false
},
"typeParams": null
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 235,
"end": 241,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 235,
"end": 240,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 235,
"end": 236,
"ctxt": 0
},
"value": "g",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 239,
"end": 240,
"ctxt": 0
},
"value": "x",
"optional": false
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 243,
"end": 268,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 247,
"end": 267,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 247,
"end": 248,
"ctxt": 0
},
"value": "h",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 248,
"end": 263,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 250,
"end": 263,
"ctxt": 0
},
"members": [
{
"type": "TsMethodSignature",
"span": {
"start": 252,
"end": 261,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 252,
"end": 253,
"ctxt": 0
},
"value": "f",
"optional": false
},
"computed": false,
"optional": false,
"params": [],
"typeAnn": {
"type": "TsTypeAnnotation",
"span": {
"start": 255,
"end": 261,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 257,
"end": 261,
"ctxt": 0
},
"kind": "void"
}
},
"typeParams": null
}
]
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 266,
"end": 267,
"ctxt": 0
},
"value": "x",
"optional": false
},
"definite": false
}
]
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 279,
"end": 280,
"ctxt": 0
},
"value": "i",
"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": "a",
"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": 270,
"end": 304,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 290,
"end": 304,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 296,
"end": 302,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 296,
"end": 301,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 296,
"end": 297,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 300,
"end": 301,
"ctxt": 0
},
"value": "x",
"optional": false
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 280,
"end": 283,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 281,
"end": 282,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 281,
"end": 282,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
},
"returnType": null
}
],
"interpreter": null
}