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

1039 lines
24 KiB
JSON

{
"type": "Script",
"span": {
"start": 1,
"end": 355,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 1,
"end": 12,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 5,
"end": 11,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 5,
"end": 7,
"ctxt": 0
},
"value": "t0",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 7,
"end": 11,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTupleType",
"span": {
"start": 9,
"end": 11,
"ctxt": 0
},
"elemTypes": []
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 13,
"end": 30,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 17,
"end": 29,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 17,
"end": 19,
"ctxt": 0
},
"value": "t1",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 19,
"end": 29,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTupleType",
"span": {
"start": 21,
"end": 29,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 22,
"end": 28,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 22,
"end": 28,
"ctxt": 0
},
"kind": "number"
}
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 31,
"end": 56,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 35,
"end": 55,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 35,
"end": 37,
"ctxt": 0
},
"value": "t2",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 37,
"end": 55,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTupleType",
"span": {
"start": 39,
"end": 55,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 40,
"end": 46,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 40,
"end": 46,
"ctxt": 0
},
"kind": "number"
}
},
{
"type": "TsTupleElement",
"span": {
"start": 48,
"end": 54,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 48,
"end": 54,
"ctxt": 0
},
"kind": "number"
}
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 57,
"end": 75,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 61,
"end": 74,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 61,
"end": 64,
"ctxt": 0
},
"value": "arr",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 64,
"end": 74,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsArrayType",
"span": {
"start": 66,
"end": 74,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 66,
"end": 72,
"ctxt": 0
},
"kind": "number"
}
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 77,
"end": 101,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 81,
"end": 100,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 81,
"end": 85,
"ctxt": 0
},
"value": "len0",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 85,
"end": 88,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 87,
"end": 88,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 87,
"end": 88,
"ctxt": 0
},
"value": 0.0,
"raw": "0"
}
}
}
},
"init": {
"type": "MemberExpression",
"span": {
"start": 91,
"end": 100,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 91,
"end": 93,
"ctxt": 0
},
"value": "t0",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 94,
"end": 100,
"ctxt": 0
},
"value": "length",
"optional": false
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 102,
"end": 126,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 106,
"end": 125,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 106,
"end": 110,
"ctxt": 0
},
"value": "len1",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 110,
"end": 113,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 112,
"end": 113,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 112,
"end": 113,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
}
}
},
"init": {
"type": "MemberExpression",
"span": {
"start": 116,
"end": 125,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 116,
"end": 118,
"ctxt": 0
},
"value": "t1",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 119,
"end": 125,
"ctxt": 0
},
"value": "length",
"optional": false
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 127,
"end": 151,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 131,
"end": 150,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 131,
"end": 135,
"ctxt": 0
},
"value": "len2",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 135,
"end": 138,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 137,
"end": 138,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 137,
"end": 138,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
}
}
}
},
"init": {
"type": "MemberExpression",
"span": {
"start": 141,
"end": 150,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 141,
"end": 143,
"ctxt": 0
},
"value": "t2",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 144,
"end": 150,
"ctxt": 0
},
"value": "length",
"optional": false
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 152,
"end": 182,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 156,
"end": 181,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 156,
"end": 160,
"ctxt": 0
},
"value": "lena",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 160,
"end": 168,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 162,
"end": 168,
"ctxt": 0
},
"kind": "number"
}
}
},
"init": {
"type": "MemberExpression",
"span": {
"start": 171,
"end": 181,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 171,
"end": 174,
"ctxt": 0
},
"value": "arr",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 175,
"end": 181,
"ctxt": 0
},
"value": "length",
"optional": false
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 184,
"end": 196,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 188,
"end": 195,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 188,
"end": 190,
"ctxt": 0
},
"value": "t1",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "Identifier",
"span": {
"start": 193,
"end": 195,
"ctxt": 0
},
"value": "t2",
"optional": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 206,
"end": 218,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 210,
"end": 217,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 210,
"end": 212,
"ctxt": 0
},
"value": "t2",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "Identifier",
"span": {
"start": 215,
"end": 217,
"ctxt": 0
},
"value": "t1",
"optional": false
},
"definite": false
}
]
},
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 229,
"end": 267,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 234,
"end": 235,
"ctxt": 0
},
"value": "A",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 235,
"end": 252,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 236,
"end": 251,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 236,
"end": 237,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": {
"type": "TsArrayType",
"span": {
"start": 246,
"end": 251,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 246,
"end": 249,
"ctxt": 0
},
"kind": "any"
}
},
"default": null
}
]
},
"typeAnnotation": {
"type": "TsIndexedAccessType",
"span": {
"start": 255,
"end": 266,
"ctxt": 0
},
"readonly": false,
"objectType": {
"type": "TsTypeReference",
"span": {
"start": 255,
"end": 256,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 255,
"end": 256,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
},
"indexType": {
"type": "TsLiteralType",
"span": {
"start": 257,
"end": 265,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
"start": 257,
"end": 265,
"ctxt": 0
},
"value": "length",
"raw": "'length'"
}
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 268,
"end": 288,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 272,
"end": 287,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 272,
"end": 273,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 273,
"end": 287,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 275,
"end": 287,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 275,
"end": 276,
"ctxt": 0
},
"value": "A",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 276,
"end": 287,
"ctxt": 0
},
"params": [
{
"type": "TsTupleType",
"span": {
"start": 277,
"end": 286,
"ctxt": 0
},
"elemTypes": [
{
"type": "TsTupleElement",
"span": {
"start": 278,
"end": 285,
"ctxt": 0
},
"label": null,
"ty": {
"type": "TsKeywordType",
"span": {
"start": 278,
"end": 285,
"ctxt": 0
},
"kind": "boolean"
}
}
]
}
]
}
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 289,
"end": 302,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 293,
"end": 301,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 293,
"end": 294,
"ctxt": 0
},
"value": "c",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 294,
"end": 297,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsLiteralType",
"span": {
"start": 296,
"end": 297,
"ctxt": 0
},
"literal": {
"type": "NumericLiteral",
"span": {
"start": 296,
"end": 297,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
}
}
},
"init": {
"type": "Identifier",
"span": {
"start": 300,
"end": 301,
"ctxt": 0
},
"value": "b",
"optional": false
},
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 304,
"end": 313,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 304,
"end": 312,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 304,
"end": 306,
"ctxt": 0
},
"value": "t1",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 309,
"end": 312,
"ctxt": 0
},
"value": "arr",
"optional": false
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 346,
"end": 355,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 346,
"end": 354,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 346,
"end": 349,
"ctxt": 0
},
"value": "arr",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 352,
"end": 354,
"ctxt": 0
},
"value": "t1",
"optional": false
}
}
}
],
"interpreter": null
}