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

1194 lines
26 KiB
JSON

{
"type": "Script",
"span": {
"start": 0,
"end": 304,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 0,
"end": 24,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 4,
"end": 23,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 4,
"end": 5,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 5,
"end": 23,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeQuery",
"span": {
"start": 7,
"end": 23,
"ctxt": 0
},
"exprName": {
"type": "Identifier",
"span": {
"start": 14,
"end": 23,
"ctxt": 0
},
"value": "undefined",
"optional": false
},
"typeArguments": null
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 26,
"end": 32,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 26,
"end": 31,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 26,
"end": 27,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 30,
"end": 31,
"ctxt": 0
},
"value": 1.0
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 33,
"end": 40,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 33,
"end": 39,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 33,
"end": 34,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 37,
"end": 39,
"ctxt": 0
},
"value": "",
"raw": "''"
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 41,
"end": 50,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 41,
"end": 49,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 41,
"end": 42,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "BooleanLiteral",
"span": {
"start": 45,
"end": 49,
"ctxt": 0
},
"value": true
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 51,
"end": 63,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 55,
"end": 62,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 55,
"end": 56,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 56,
"end": 62,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 58,
"end": 62,
"ctxt": 0
},
"kind": "void"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 64,
"end": 70,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 64,
"end": 69,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 64,
"end": 65,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 68,
"end": 69,
"ctxt": 0
},
"value": "a",
"optional": false
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 71,
"end": 80,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 71,
"end": 79,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 71,
"end": 72,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NullLiteral",
"span": {
"start": 75,
"end": 79,
"ctxt": 0
}
}
}
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 88,
"end": 89,
"ctxt": 0
},
"value": "C",
"optional": false
},
"declare": false,
"span": {
"start": 82,
"end": 105,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 92,
"end": 103,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 92,
"end": 95,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 95,
"end": 103,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 97,
"end": 103,
"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": 106,
"end": 115,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 110,
"end": 114,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 110,
"end": 111,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 111,
"end": 114,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 113,
"end": 114,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 113,
"end": 114,
"ctxt": 0
},
"value": "C",
"optional": false
},
"typeParams": null
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 116,
"end": 122,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 116,
"end": 121,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 116,
"end": 117,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 120,
"end": 121,
"ctxt": 0
},
"value": "C",
"optional": false
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 123,
"end": 129,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 123,
"end": 128,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 123,
"end": 124,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 127,
"end": 128,
"ctxt": 0
},
"value": "b",
"optional": false
}
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 131,
"end": 158,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 141,
"end": 142,
"ctxt": 0
},
"value": "I",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 143,
"end": 158,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 145,
"end": 156,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 145,
"end": 148,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 148,
"end": 156,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 150,
"end": 156,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 159,
"end": 168,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 163,
"end": 167,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 163,
"end": 164,
"ctxt": 0
},
"value": "c",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 164,
"end": 167,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 166,
"end": 167,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 166,
"end": 167,
"ctxt": 0
},
"value": "I",
"optional": false
},
"typeParams": null
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 169,
"end": 175,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 169,
"end": 174,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 169,
"end": 170,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 173,
"end": 174,
"ctxt": 0
},
"value": "c",
"optional": false
}
}
},
{
"type": "TsModuleDeclaration",
"span": {
"start": 177,
"end": 207,
"ctxt": 0
},
"declare": false,
"global": false,
"id": {
"type": "Identifier",
"span": {
"start": 184,
"end": 185,
"ctxt": 0
},
"value": "M",
"optional": false
},
"body": {
"type": "TsModuleBlock",
"span": {
"start": 186,
"end": 207,
"ctxt": 0
},
"body": [
{
"type": "ExportDeclaration",
"span": {
"start": 188,
"end": 205,
"ctxt": 0
},
"declaration": {
"type": "VariableDeclaration",
"span": {
"start": 195,
"end": 205,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 199,
"end": 204,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 199,
"end": 200,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "NumericLiteral",
"span": {
"start": 203,
"end": 204,
"ctxt": 0
},
"value": 1.0
},
"definite": false
}
]
}
}
]
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 208,
"end": 214,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 208,
"end": 213,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 208,
"end": 209,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 212,
"end": 213,
"ctxt": 0
},
"value": "M",
"optional": false
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 216,
"end": 231,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 216,
"end": 231,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 216,
"end": 217,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "ObjectExpression",
"span": {
"start": 220,
"end": 231,
"ctxt": 0
},
"properties": [
{
"type": "MethodProperty",
"key": {
"type": "Identifier",
"span": {
"start": 222,
"end": 223,
"ctxt": 0
},
"value": "f",
"optional": false
},
"params": [],
"decorators": [],
"span": {
"start": 222,
"end": 229,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 226,
"end": 229,
"ctxt": 0
},
"stmts": []
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
]
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 242,
"end": 243,
"ctxt": 0
},
"value": "f",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 247,
"end": 251,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 247,
"end": 251,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 248,
"end": 251,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 250,
"end": 251,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 250,
"end": 251,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
],
"decorators": [],
"span": {
"start": 233,
"end": 267,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 253,
"end": 267,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 259,
"end": 265,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 259,
"end": 264,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 259,
"end": 260,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 263,
"end": 264,
"ctxt": 0
},
"value": "a",
"optional": false
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 243,
"end": 246,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 244,
"end": 245,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 244,
"end": 245,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
},
"returnType": null
},
{
"type": "ExpressionStatement",
"span": {
"start": 268,
"end": 274,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 268,
"end": 273,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 268,
"end": 269,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 272,
"end": 273,
"ctxt": 0
},
"value": "f",
"optional": false
}
}
},
{
"type": "TsEnumDeclaration",
"span": {
"start": 276,
"end": 288,
"ctxt": 0
},
"declare": false,
"isConst": false,
"id": {
"type": "Identifier",
"span": {
"start": 281,
"end": 282,
"ctxt": 0
},
"value": "E",
"optional": false
},
"members": [
{
"type": "TsEnumMember",
"span": {
"start": 285,
"end": 286,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 285,
"end": 286,
"ctxt": 0
},
"value": "A",
"optional": false
},
"init": null
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 289,
"end": 295,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 289,
"end": 294,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 289,
"end": 290,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 293,
"end": 294,
"ctxt": 0
},
"value": "E",
"optional": false
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 296,
"end": 304,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 296,
"end": 303,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 296,
"end": 297,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "MemberExpression",
"span": {
"start": 300,
"end": 303,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 300,
"end": 301,
"ctxt": 0
},
"value": "E",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 302,
"end": 303,
"ctxt": 0
},
"value": "A",
"optional": false
}
}
}
}
],
"interpreter": null
}