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

1235 lines
28 KiB
JSON

{
"type": "Script",
"span": {
"start": 0,
"end": 444,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 0,
"end": 21,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 4,
"end": 20,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 4,
"end": 5,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 5,
"end": 13,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 7,
"end": 13,
"ctxt": 0
},
"kind": "number"
}
}
},
"init": {
"type": "NullLiteral",
"span": {
"start": 16,
"end": 20,
"ctxt": 0
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 22,
"end": 44,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 26,
"end": 43,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 26,
"end": 27,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 27,
"end": 36,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 29,
"end": 36,
"ctxt": 0
},
"kind": "boolean"
}
}
},
"init": {
"type": "NullLiteral",
"span": {
"start": 39,
"end": 43,
"ctxt": 0
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 45,
"end": 66,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 49,
"end": 65,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 49,
"end": 50,
"ctxt": 0
},
"value": "c",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 50,
"end": 58,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 52,
"end": 58,
"ctxt": 0
},
"kind": "string"
}
}
},
"init": {
"type": "NullLiteral",
"span": {
"start": 61,
"end": 65,
"ctxt": 0
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 67,
"end": 86,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 71,
"end": 85,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 71,
"end": 72,
"ctxt": 0
},
"value": "d",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 72,
"end": 78,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 74,
"end": 78,
"ctxt": 0
},
"kind": "void"
}
}
},
"init": {
"type": "NullLiteral",
"span": {
"start": 81,
"end": 85,
"ctxt": 0
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 88,
"end": 119,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 92,
"end": 118,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 92,
"end": 93,
"ctxt": 0
},
"value": "e",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 93,
"end": 111,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeQuery",
"span": {
"start": 95,
"end": 111,
"ctxt": 0
},
"exprName": {
"type": "Identifier",
"span": {
"start": 102,
"end": 111,
"ctxt": 0
},
"value": "undefined",
"optional": false
},
"typeArguments": null
}
}
},
"init": {
"type": "NullLiteral",
"span": {
"start": 114,
"end": 118,
"ctxt": 0
}
},
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 120,
"end": 129,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 120,
"end": 128,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 120,
"end": 121,
"ctxt": 0
},
"value": "e",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NullLiteral",
"span": {
"start": 124,
"end": 128,
"ctxt": 0
}
}
}
},
{
"type": "TsEnumDeclaration",
"span": {
"start": 137,
"end": 149,
"ctxt": 0
},
"declare": false,
"isConst": false,
"id": {
"type": "Identifier",
"span": {
"start": 142,
"end": 143,
"ctxt": 0
},
"value": "E",
"optional": false
},
"members": [
{
"type": "TsEnumMember",
"span": {
"start": 146,
"end": 147,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 146,
"end": 147,
"ctxt": 0
},
"value": "A",
"optional": false
},
"init": null
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 150,
"end": 161,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 150,
"end": 160,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 150,
"end": 153,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 150,
"end": 151,
"ctxt": 0
},
"value": "E",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 152,
"end": 153,
"ctxt": 0
},
"value": "A",
"optional": false
}
},
"right": {
"type": "NullLiteral",
"span": {
"start": 156,
"end": 160,
"ctxt": 0
}
}
}
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 178,
"end": 179,
"ctxt": 0
},
"value": "C",
"optional": false
},
"declare": false,
"span": {
"start": 172,
"end": 195,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 182,
"end": 193,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 182,
"end": 185,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 185,
"end": 193,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 187,
"end": 193,
"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": 196,
"end": 205,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 200,
"end": 204,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 200,
"end": 201,
"ctxt": 0
},
"value": "f",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 201,
"end": 204,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 203,
"end": 204,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 203,
"end": 204,
"ctxt": 0
},
"value": "C",
"optional": false
},
"typeParams": null
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 206,
"end": 215,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 206,
"end": 214,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 206,
"end": 207,
"ctxt": 0
},
"value": "f",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NullLiteral",
"span": {
"start": 210,
"end": 214,
"ctxt": 0
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 222,
"end": 231,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 222,
"end": 230,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 222,
"end": 223,
"ctxt": 0
},
"value": "C",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NullLiteral",
"span": {
"start": 226,
"end": 230,
"ctxt": 0
}
}
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 242,
"end": 269,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 252,
"end": 253,
"ctxt": 0
},
"value": "I",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 254,
"end": 269,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 256,
"end": 267,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 256,
"end": 259,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 259,
"end": 267,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 261,
"end": 267,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 270,
"end": 279,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 274,
"end": 278,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 274,
"end": 275,
"ctxt": 0
},
"value": "g",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 275,
"end": 278,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 277,
"end": 278,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 277,
"end": 278,
"ctxt": 0
},
"value": "I",
"optional": false
},
"typeParams": null
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 280,
"end": 289,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 280,
"end": 288,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 280,
"end": 281,
"ctxt": 0
},
"value": "g",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NullLiteral",
"span": {
"start": 284,
"end": 288,
"ctxt": 0
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 296,
"end": 305,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 296,
"end": 304,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 296,
"end": 297,
"ctxt": 0
},
"value": "I",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NullLiteral",
"span": {
"start": 300,
"end": 304,
"ctxt": 0
}
}
}
},
{
"type": "TsModuleDeclaration",
"span": {
"start": 316,
"end": 346,
"ctxt": 0
},
"declare": false,
"global": false,
"id": {
"type": "Identifier",
"span": {
"start": 323,
"end": 324,
"ctxt": 0
},
"value": "M",
"optional": false
},
"body": {
"type": "TsModuleBlock",
"span": {
"start": 325,
"end": 346,
"ctxt": 0
},
"body": [
{
"type": "ExportDeclaration",
"span": {
"start": 327,
"end": 344,
"ctxt": 0
},
"declaration": {
"type": "VariableDeclaration",
"span": {
"start": 334,
"end": 344,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 338,
"end": 343,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 338,
"end": 339,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "NumericLiteral",
"span": {
"start": 342,
"end": 343,
"ctxt": 0
},
"value": 1.0
},
"definite": false
}
]
}
}
]
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 347,
"end": 356,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 347,
"end": 355,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 347,
"end": 348,
"ctxt": 0
},
"value": "M",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NullLiteral",
"span": {
"start": 351,
"end": 355,
"ctxt": 0
}
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 367,
"end": 395,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 371,
"end": 394,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 371,
"end": 372,
"ctxt": 0
},
"value": "h",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 372,
"end": 387,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 374,
"end": 387,
"ctxt": 0
},
"members": [
{
"type": "TsMethodSignature",
"span": {
"start": 376,
"end": 385,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 376,
"end": 377,
"ctxt": 0
},
"value": "f",
"optional": false
},
"computed": false,
"optional": false,
"params": [],
"typeAnn": {
"type": "TsTypeAnnotation",
"span": {
"start": 379,
"end": 385,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 381,
"end": 385,
"ctxt": 0
},
"kind": "void"
}
},
"typeParams": null
}
]
}
}
},
"init": {
"type": "NullLiteral",
"span": {
"start": 390,
"end": 394,
"ctxt": 0
}
},
"definite": false
}
]
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 406,
"end": 407,
"ctxt": 0
},
"value": "i",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 411,
"end": 415,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 411,
"end": 415,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 412,
"end": 415,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 414,
"end": 415,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 414,
"end": 415,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
],
"decorators": [],
"span": {
"start": 397,
"end": 434,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 417,
"end": 434,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 423,
"end": 432,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 423,
"end": 431,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 423,
"end": 424,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NullLiteral",
"span": {
"start": 427,
"end": 431,
"ctxt": 0
}
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 407,
"end": 410,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 408,
"end": 409,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 408,
"end": 409,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
},
"returnType": null
},
{
"type": "ExpressionStatement",
"span": {
"start": 435,
"end": 444,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 435,
"end": 443,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 435,
"end": 436,
"ctxt": 0
},
"value": "i",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NullLiteral",
"span": {
"start": 439,
"end": 443,
"ctxt": 0
}
}
}
}
],
"interpreter": null
}