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

1037 lines
24 KiB
JSON

{
"type": "Script",
"span": {
"start": 0,
"end": 354,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 0,
"end": 11,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 4,
"end": 10,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 4,
"end": 6,
"ctxt": 0
},
"value": "t0",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 6,
"end": 10,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTupleType",
"span": {
"start": 8,
"end": 10,
"ctxt": 0
},
"elemTypes": []
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 12,
"end": 29,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 16,
"end": 28,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 16,
"end": 18,
"ctxt": 0
},
"value": "t1",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 18,
"end": 28,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTupleType",
"span": {
"start": 20,
"end": 28,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 21,
"end": 27,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 21,
"end": 27,
"ctxt": 0
},
"kind": "number"
}
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 30,
"end": 55,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 34,
"end": 54,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 34,
"end": 36,
"ctxt": 0
},
"value": "t2",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 36,
"end": 54,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTupleType",
"span": {
"start": 38,
"end": 54,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 39,
"end": 45,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 39,
"end": 45,
"ctxt": 0
},
"kind": "number"
}
},
{
"type": "TsTupleElement",
"span": {
"start": 47,
"end": 53,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 47,
"end": 53,
"ctxt": 0
},
"kind": "number"
}
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 56,
"end": 74,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 60,
"end": 73,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 60,
"end": 63,
"ctxt": 0
},
"value": "arr",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 63,
"end": 73,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsArrayType",
"span": {
"start": 65,
"end": 73,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 65,
"end": 71,
"ctxt": 0
},
"kind": "number"
}
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 76,
"end": 100,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 80,
"end": 99,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 80,
"end": 84,
"ctxt": 0
},
"value": "len0",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 84,
"end": 87,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 86,
"end": 87,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 86,
"end": 87,
"ctxt": 0
},
"value": 0.0
}
}
}
},
"init": {
"type": "MemberExpression",
"span": {
"start": 90,
"end": 99,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 90,
"end": 92,
"ctxt": 0
},
"value": "t0",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 93,
"end": 99,
"ctxt": 0
},
"value": "length",
"optional": false
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 101,
"end": 125,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 105,
"end": 124,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 105,
"end": 109,
"ctxt": 0
},
"value": "len1",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 109,
"end": 112,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 111,
"end": 112,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 111,
"end": 112,
"ctxt": 0
},
"value": 1.0
}
}
}
},
"init": {
"type": "MemberExpression",
"span": {
"start": 115,
"end": 124,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 115,
"end": 117,
"ctxt": 0
},
"value": "t1",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 118,
"end": 124,
"ctxt": 0
},
"value": "length",
"optional": false
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 126,
"end": 150,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 130,
"end": 149,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 130,
"end": 134,
"ctxt": 0
},
"value": "len2",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 134,
"end": 137,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 136,
"end": 137,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 136,
"end": 137,
"ctxt": 0
},
"value": 2.0
}
}
}
},
"init": {
"type": "MemberExpression",
"span": {
"start": 140,
"end": 149,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 140,
"end": 142,
"ctxt": 0
},
"value": "t2",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 143,
"end": 149,
"ctxt": 0
},
"value": "length",
"optional": false
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 151,
"end": 181,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 155,
"end": 180,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 155,
"end": 159,
"ctxt": 0
},
"value": "lena",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 159,
"end": 167,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 161,
"end": 167,
"ctxt": 0
},
"kind": "number"
}
}
},
"init": {
"type": "MemberExpression",
"span": {
"start": 170,
"end": 180,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 170,
"end": 173,
"ctxt": 0
},
"value": "arr",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 174,
"end": 180,
"ctxt": 0
},
"value": "length",
"optional": false
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 183,
"end": 195,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 187,
"end": 194,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 187,
"end": 189,
"ctxt": 0
},
"value": "t1",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "Identifier",
"span": {
"start": 192,
"end": 194,
"ctxt": 0
},
"value": "t2",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 205,
"end": 217,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 209,
"end": 216,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 209,
"end": 211,
"ctxt": 0
},
"value": "t2",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "Identifier",
"span": {
"start": 214,
"end": 216,
"ctxt": 0
},
"value": "t1",
"optional": false
},
"definite": false
}
]
},
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 228,
"end": 266,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 233,
"end": 234,
"ctxt": 0
},
"value": "A",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 234,
"end": 251,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 235,
"end": 250,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 235,
"end": 236,
"ctxt": 0
},
"value": "T",
"optional": false
},
"constraint": {
"type": "TsArrayType",
"span": {
"start": 245,
"end": 250,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 245,
"end": 248,
"ctxt": 0
},
"kind": "any"
}
},
"default": null
}
]
},
"typeAnnotation": {
"type": "TsIndexedAccessType",
"span": {
"start": 254,
"end": 265,
"ctxt": 0
},
"readonly": false,
"objectType": {
"type": "TsTypeReference",
"span": {
"start": 254,
"end": 255,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 254,
"end": 255,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
},
"indexType": {
"type": "TsLiteralType",
"span": {
"start": 256,
"end": 264,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
"start": 256,
"end": 264,
"ctxt": 0
},
"value": "length",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 267,
"end": 287,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 271,
"end": 286,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 271,
"end": 272,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 272,
"end": 286,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 274,
"end": 286,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 274,
"end": 275,
"ctxt": 0
},
"value": "A",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 275,
"end": 286,
"ctxt": 0
},
"params": [
{
"type": "TsTupleType",
"span": {
"start": 276,
"end": 285,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 277,
"end": 284,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 277,
"end": 284,
"ctxt": 0
},
"kind": "boolean"
}
}
]
}
]
}
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 288,
"end": 301,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 292,
"end": 300,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 292,
"end": 293,
"ctxt": 0
},
"value": "c",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 293,
"end": 296,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 295,
"end": 296,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 295,
"end": 296,
"ctxt": 0
},
"value": 1.0
}
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 299,
"end": 300,
"ctxt": 0
},
"value": "b",
"optional": false
},
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 303,
"end": 312,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 303,
"end": 311,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 303,
"end": 305,
"ctxt": 0
},
"value": "t1",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 308,
"end": 311,
"ctxt": 0
},
"value": "arr",
"optional": false
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 345,
"end": 354,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 345,
"end": 353,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 345,
"end": 348,
"ctxt": 0
},
"value": "arr",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 351,
"end": 353,
"ctxt": 0
},
"value": "t1",
"optional": false
}
}
}
],
"interpreter": null
}