From 95c13fe7583458286a840429a856ab20be6db20a Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Mon, 30 Sep 2019 09:31:44 -0700 Subject: [PATCH] fix(typescript-estree): handle optional computed prop w/o type (#1026) --- .../lib/__snapshots__/typescript.ts.snap | 269 ++- .../class-with-optional-properties.src.ts | 8 + packages/typescript-estree/src/convert.ts | 6 +- .../lib/__snapshots__/typescript.ts.snap | 1766 ++++++++++++++--- 4 files changed, 1793 insertions(+), 256 deletions(-) diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap index a2b241e3e82..cf9bd22368c 100644 --- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap @@ -7660,68 +7660,114 @@ Object { exports[`typescript fixtures/basics/class-with-optional-properties.src 1`] = ` Object { - "$id": 4, + "$id": 10, "block": Object { "range": Array [ 0, - 64, + 219, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 3, + "$id": 9, "block": Object { "range": Array [ 0, - 64, + 219, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 2, + "$id": 8, "block": Object { "range": Array [ - 0, - 63, + 51, + 218, ], "type": "ClassDeclaration", }, "childScopes": Array [], "functionExpressionScope": false, "isStrict": true, - "references": Array [], - "throughReferences": Array [], + "references": Array [ + Object { + "$id": 6, + "from": Object { + "$ref": 8, + }, + "identifier": Object { + "name": "computed", + "range": Array [ + 116, + 124, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": undefined, + }, + Object { + "$id": 7, + "from": Object { + "$ref": 8, + }, + "identifier": Object { + "name": "computed2", + "range": Array [ + 155, + 164, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": Object { + "$ref": 1, + }, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 6, + }, + Object { + "$ref": 7, + }, + ], "type": "class", "upperScope": Object { - "$ref": 3, + "$ref": 9, }, "variableMap": Object { "Foo": Object { - "$ref": 1, + "$ref": 5, }, }, "variableScope": Object { - "$ref": 3, + "$ref": 9, }, "variables": Array [ Object { - "$id": 1, + "$id": 5, "defs": Array [ Object { "name": Object { "name": "Foo", "range": Array [ - 6, - 9, + 57, + 60, ], "type": "Identifier", }, "node": Object { "range": Array [ - 0, - 63, + 51, + 218, ], "type": "ClassDeclaration", }, @@ -7734,8 +7780,8 @@ Object { Object { "name": "Foo", "range": Array [ - 6, - 9, + 57, + 60, ], "type": "Identifier", }, @@ -7743,7 +7789,7 @@ Object { "name": "Foo", "references": Array [], "scope": Object { - "$ref": 2, + "$ref": 8, }, }, ], @@ -7751,19 +7797,76 @@ Object { ], "functionExpressionScope": false, "isStrict": true, - "references": Array [], + "references": Array [ + Object { + "$id": 3, + "from": Object { + "$ref": 9, + }, + "identifier": Object { + "name": "computed", + "range": Array [ + 6, + 14, + ], + "type": "Identifier", + }, + "kind": "w", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": Object { + "range": Array [ + 17, + 23, + ], + "type": "Literal", + }, + }, + Object { + "$id": 4, + "from": Object { + "$ref": 9, + }, + "identifier": Object { + "name": "computed2", + "range": Array [ + 31, + 40, + ], + "type": "Identifier", + }, + "kind": "w", + "resolved": Object { + "$ref": 1, + }, + "writeExpr": Object { + "range": Array [ + 43, + 49, + ], + "type": "Literal", + }, + }, + ], "throughReferences": Array [], "type": "module", "upperScope": Object { - "$ref": 4, + "$ref": 10, }, "variableMap": Object { "Foo": Object { + "$ref": 2, + }, + "computed": Object { "$ref": 0, }, + "computed2": Object { + "$ref": 1, + }, }, "variableScope": Object { - "$ref": 3, + "$ref": 9, }, "variables": Array [ Object { @@ -7771,17 +7874,123 @@ Object { "defs": Array [ Object { "name": Object { - "name": "Foo", + "name": "computed", "range": Array [ 6, - 9, + 14, ], "type": "Identifier", }, "node": Object { + "range": Array [ + 6, + 23, + ], + "type": "VariableDeclarator", + }, + "parent": Object { "range": Array [ 0, - 63, + 24, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "computed", + "range": Array [ + 6, + 14, + ], + "type": "Identifier", + }, + ], + "name": "computed", + "references": Array [ + Object { + "$ref": 3, + }, + Object { + "$ref": 6, + }, + ], + "scope": Object { + "$ref": 9, + }, + }, + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "computed2", + "range": Array [ + 31, + 40, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 31, + 49, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 25, + 50, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "computed2", + "range": Array [ + 31, + 40, + ], + "type": "Identifier", + }, + ], + "name": "computed2", + "references": Array [ + Object { + "$ref": 4, + }, + Object { + "$ref": 7, + }, + ], + "scope": Object { + "$ref": 9, + }, + }, + Object { + "$id": 2, + "defs": Array [ + Object { + "name": Object { + "name": "Foo", + "range": Array [ + 57, + 60, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 51, + 218, ], "type": "ClassDeclaration", }, @@ -7794,8 +8003,8 @@ Object { Object { "name": "Foo", "range": Array [ - 6, - 9, + 57, + 60, ], "type": "Identifier", }, @@ -7803,7 +8012,7 @@ Object { "name": "Foo", "references": Array [], "scope": Object { - "$ref": 3, + "$ref": 9, }, }, ], @@ -7817,7 +8026,7 @@ Object { "upperScope": null, "variableMap": Object {}, "variableScope": Object { - "$ref": 4, + "$ref": 10, }, "variables": Array [], } diff --git a/packages/shared-fixtures/fixtures/typescript/basics/class-with-optional-properties.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-with-optional-properties.src.ts index 536aab8062d..e9292de2e06 100644 --- a/packages/shared-fixtures/fixtures/typescript/basics/class-with-optional-properties.src.ts +++ b/packages/shared-fixtures/fixtures/typescript/basics/class-with-optional-properties.src.ts @@ -1,5 +1,13 @@ +const computed = 'buzz'; +const computed2 = 'bazz'; class Foo { foo?; bar? : string; private baz? : string; + [computed]?; + ['literal']?; + [1]?; + [computed2]?: string; + ['literal2']?: string; + [2]?: string; } diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 43ab7889c6b..203fbe2b494 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -941,7 +941,11 @@ export class Converter { result.accessibility = accessibility; } - if (node.name.kind === SyntaxKind.Identifier && node.questionToken) { + if ( + (node.name.kind === SyntaxKind.Identifier || + node.name.kind === SyntaxKind.ComputedPropertyName) && + node.questionToken + ) { result.optional = true; } diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap index 3b31431ff71..5cbee776bf2 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap @@ -21093,6 +21093,154 @@ Object { exports[`typescript fixtures/basics/class-with-optional-properties.src 1`] = ` Object { "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "computed", + "range": Array [ + 6, + 14, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 23, + ], + "raw": "'buzz'", + "type": "Literal", + "value": "buzz", + }, + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 23, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 24, + ], + "type": "VariableDeclaration", + }, + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "name": "computed2", + "range": Array [ + 31, + 40, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "range": Array [ + 43, + 49, + ], + "raw": "'bazz'", + "type": "Literal", + "value": "bazz", + }, + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 31, + 49, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 25, + 50, + ], + "type": "VariableDeclaration", + }, Object { "body": Object { "body": Array [ @@ -21102,34 +21250,34 @@ Object { "loc": Object { "end": Object { "column": 5, - "line": 2, + "line": 4, }, "start": Object { "column": 2, - "line": 2, + "line": 4, }, }, "name": "foo", "range": Array [ - 14, - 17, + 65, + 68, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 7, - "line": 2, + "line": 4, }, "start": Object { "column": 2, - "line": 2, + "line": 4, }, }, "optional": true, "range": Array [ - 14, - 19, + 65, + 70, ], "static": false, "type": "ClassProperty", @@ -21141,34 +21289,34 @@ Object { "loc": Object { "end": Object { "column": 5, - "line": 3, + "line": 5, }, "start": Object { "column": 2, - "line": 3, + "line": 5, }, }, "name": "bar", "range": Array [ - 22, - 25, + 73, + 76, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 16, - "line": 3, + "line": 5, }, "start": Object { "column": 2, - "line": 3, + "line": 5, }, }, "optional": true, "range": Array [ - 22, - 36, + 73, + 87, ], "static": false, "type": "ClassProperty", @@ -21176,32 +21324,32 @@ Object { "loc": Object { "end": Object { "column": 15, - "line": 3, + "line": 5, }, "start": Object { "column": 7, - "line": 3, + "line": 5, }, }, "range": Array [ - 27, - 35, + 78, + 86, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { "column": 15, - "line": 3, + "line": 5, }, "start": Object { "column": 9, - "line": 3, + "line": 5, }, }, "range": Array [ - 29, - 35, + 80, + 86, ], "type": "TSStringKeyword", }, @@ -21215,34 +21363,34 @@ Object { "loc": Object { "end": Object { "column": 13, - "line": 4, + "line": 6, }, "start": Object { "column": 10, - "line": 4, + "line": 6, }, }, "name": "baz", "range": Array [ - 47, - 50, + 98, + 101, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 24, - "line": 4, + "line": 6, }, "start": Object { "column": 2, - "line": 4, + "line": 6, }, }, "optional": true, "range": Array [ - 39, - 61, + 90, + 112, ], "static": false, "type": "ClassProperty", @@ -21250,355 +21398,1523 @@ Object { "loc": Object { "end": Object { "column": 23, - "line": 4, + "line": 6, }, "start": Object { "column": 15, - "line": 4, + "line": 6, }, }, "range": Array [ - 52, - 60, + 103, + 111, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { "column": 23, - "line": 4, + "line": 6, }, "start": Object { "column": 17, - "line": 4, + "line": 6, }, }, "range": Array [ - 54, - 60, + 105, + 111, ], "type": "TSStringKeyword", }, }, "value": null, }, - ], - "loc": Object { - "end": Object { - "column": 1, - "line": 5, - }, - "start": Object { - "column": 10, - "line": 1, - }, - }, - "range": Array [ - 10, - 63, - ], - "type": "ClassBody", - }, - "id": Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 1, - }, - "start": Object { - "column": 6, - "line": 1, - }, - }, - "name": "Foo", - "range": Array [ - 6, - 9, - ], - "type": "Identifier", - }, - "loc": Object { + Object { + "computed": true, + "key": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 7, + }, + "start": Object { + "column": 3, + "line": 7, + }, + }, + "name": "computed", + "range": Array [ + 116, + 124, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 14, + "line": 7, + }, + "start": Object { + "column": 2, + "line": 7, + }, + }, + "optional": true, + "range": Array [ + 115, + 127, + ], + "static": false, + "type": "ClassProperty", + "value": null, + }, + Object { + "computed": true, + "key": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 8, + }, + "start": Object { + "column": 3, + "line": 8, + }, + }, + "range": Array [ + 131, + 140, + ], + "raw": "'literal'", + "type": "Literal", + "value": "literal", + }, + "loc": Object { + "end": Object { + "column": 15, + "line": 8, + }, + "start": Object { + "column": 2, + "line": 8, + }, + }, + "optional": true, + "range": Array [ + 130, + 143, + ], + "static": false, + "type": "ClassProperty", + "value": null, + }, + Object { + "computed": true, + "key": Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 9, + }, + "start": Object { + "column": 3, + "line": 9, + }, + }, + "range": Array [ + 147, + 148, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "loc": Object { + "end": Object { + "column": 7, + "line": 9, + }, + "start": Object { + "column": 2, + "line": 9, + }, + }, + "optional": true, + "range": Array [ + 146, + 151, + ], + "static": false, + "type": "ClassProperty", + "value": null, + }, + Object { + "computed": true, + "key": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 10, + }, + "start": Object { + "column": 3, + "line": 10, + }, + }, + "name": "computed2", + "range": Array [ + 155, + 164, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 23, + "line": 10, + }, + "start": Object { + "column": 2, + "line": 10, + }, + }, + "optional": true, + "range": Array [ + 154, + 175, + ], + "static": false, + "type": "ClassProperty", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 10, + }, + "start": Object { + "column": 14, + "line": 10, + }, + }, + "range": Array [ + 166, + 174, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 10, + }, + "start": Object { + "column": 16, + "line": 10, + }, + }, + "range": Array [ + 168, + 174, + ], + "type": "TSStringKeyword", + }, + }, + "value": null, + }, + Object { + "computed": true, + "key": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 11, + }, + "start": Object { + "column": 3, + "line": 11, + }, + }, + "range": Array [ + 179, + 189, + ], + "raw": "'literal2'", + "type": "Literal", + "value": "literal2", + }, + "loc": Object { + "end": Object { + "column": 24, + "line": 11, + }, + "start": Object { + "column": 2, + "line": 11, + }, + }, + "optional": true, + "range": Array [ + 178, + 200, + ], + "static": false, + "type": "ClassProperty", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 11, + }, + "start": Object { + "column": 15, + "line": 11, + }, + }, + "range": Array [ + 191, + 199, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 11, + }, + "start": Object { + "column": 17, + "line": 11, + }, + }, + "range": Array [ + 193, + 199, + ], + "type": "TSStringKeyword", + }, + }, + "value": null, + }, + Object { + "computed": true, + "key": Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 12, + }, + "start": Object { + "column": 3, + "line": 12, + }, + }, + "range": Array [ + 204, + 205, + ], + "raw": "2", + "type": "Literal", + "value": 2, + }, + "loc": Object { + "end": Object { + "column": 15, + "line": 12, + }, + "start": Object { + "column": 2, + "line": 12, + }, + }, + "optional": true, + "range": Array [ + 203, + 216, + ], + "static": false, + "type": "ClassProperty", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 12, + }, + "start": Object { + "column": 6, + "line": 12, + }, + }, + "range": Array [ + 207, + 215, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 12, + }, + "start": Object { + "column": 8, + "line": 12, + }, + }, + "range": Array [ + 209, + 215, + ], + "type": "TSStringKeyword", + }, + }, + "value": null, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 13, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 61, + 218, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "name": "Foo", + "range": Array [ + 57, + 60, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 13, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 51, + 218, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 14, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 219, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 14, + ], + "type": "Identifier", + "value": "computed", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 23, + ], + "type": "String", + "value": "'buzz'", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 25, + 30, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 31, + 40, + ], + "type": "Identifier", + "value": "computed2", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 41, + 42, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "range": Array [ + 43, + 49, + ], + "type": "String", + "value": "'bazz'", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "range": Array [ + 49, + 50, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 51, + 56, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "range": Array [ + 57, + 60, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 61, + 62, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 65, + 68, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 4, + }, + "start": Object { + "column": 5, + "line": 4, + }, + }, + "range": Array [ + 68, + 69, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 4, + }, + "start": Object { + "column": 6, + "line": 4, + }, + }, + "range": Array [ + 69, + 70, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 5, + }, + "start": Object { + "column": 2, + "line": 5, + }, + }, + "range": Array [ + 73, + 76, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 5, + }, + "start": Object { + "column": 5, + "line": 5, + }, + }, + "range": Array [ + 76, + 77, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 5, + }, + "start": Object { + "column": 7, + "line": 5, + }, + }, + "range": Array [ + 78, + 79, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 5, + }, + "start": Object { + "column": 9, + "line": 5, + }, + }, + "range": Array [ + 80, + 86, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 5, + }, + "start": Object { + "column": 15, + "line": 5, + }, + }, + "range": Array [ + 86, + 87, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 6, + }, + "start": Object { + "column": 2, + "line": 6, + }, + }, + "range": Array [ + 90, + 97, + ], + "type": "Keyword", + "value": "private", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 6, + }, + "start": Object { + "column": 10, + "line": 6, + }, + }, + "range": Array [ + 98, + 101, + ], + "type": "Identifier", + "value": "baz", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 6, + }, + "start": Object { + "column": 13, + "line": 6, + }, + }, + "range": Array [ + 101, + 102, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 6, + }, + "start": Object { + "column": 15, + "line": 6, + }, + }, + "range": Array [ + 103, + 104, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 6, + }, + "start": Object { + "column": 17, + "line": 6, + }, + }, + "range": Array [ + 105, + 111, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 6, + }, + "start": Object { + "column": 23, + "line": 6, + }, + }, + "range": Array [ + 111, + 112, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 7, + }, + "start": Object { + "column": 2, + "line": 7, + }, + }, + "range": Array [ + 115, + 116, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 7, + }, + "start": Object { + "column": 3, + "line": 7, + }, + }, + "range": Array [ + 116, + 124, + ], + "type": "Identifier", + "value": "computed", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 7, + }, + "start": Object { + "column": 11, + "line": 7, + }, + }, + "range": Array [ + 124, + 125, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 7, + }, + "start": Object { + "column": 12, + "line": 7, + }, + }, + "range": Array [ + 125, + 126, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 7, + }, + "start": Object { + "column": 13, + "line": 7, + }, + }, + "range": Array [ + 126, + 127, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { "end": Object { - "column": 1, - "line": 5, + "column": 3, + "line": 8, }, "start": Object { - "column": 0, - "line": 1, + "column": 2, + "line": 8, }, }, "range": Array [ - 0, - 63, + 130, + 131, ], - "superClass": null, - "type": "ClassDeclaration", + "type": "Punctuator", + "value": "[", }, - ], - "loc": Object { - "end": Object { - "column": 0, - "line": 6, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 8, + }, + "start": Object { + "column": 3, + "line": 8, + }, + }, + "range": Array [ + 131, + 140, + ], + "type": "String", + "value": "'literal'", }, - "start": Object { - "column": 0, - "line": 1, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 8, + }, + "start": Object { + "column": 12, + "line": 8, + }, + }, + "range": Array [ + 140, + 141, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 8, + }, + "start": Object { + "column": 13, + "line": 8, + }, + }, + "range": Array [ + 141, + 142, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 8, + }, + "start": Object { + "column": 14, + "line": 8, + }, + }, + "range": Array [ + 142, + 143, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 9, + }, + "start": Object { + "column": 2, + "line": 9, + }, + }, + "range": Array [ + 146, + 147, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 9, + }, + "start": Object { + "column": 3, + "line": 9, + }, + }, + "range": Array [ + 147, + 148, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 9, + }, + "start": Object { + "column": 4, + "line": 9, + }, + }, + "range": Array [ + 148, + 149, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 9, + }, + "start": Object { + "column": 5, + "line": 9, + }, + }, + "range": Array [ + 149, + 150, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 9, + }, + "start": Object { + "column": 6, + "line": 9, + }, + }, + "range": Array [ + 150, + 151, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 10, + }, + "start": Object { + "column": 2, + "line": 10, + }, + }, + "range": Array [ + 154, + 155, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 10, + }, + "start": Object { + "column": 3, + "line": 10, + }, + }, + "range": Array [ + 155, + 164, + ], + "type": "Identifier", + "value": "computed2", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 10, + }, + "start": Object { + "column": 12, + "line": 10, + }, + }, + "range": Array [ + 164, + 165, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 10, + }, + "start": Object { + "column": 13, + "line": 10, + }, + }, + "range": Array [ + 165, + 166, + ], + "type": "Punctuator", + "value": "?", }, - }, - "range": Array [ - 0, - 64, - ], - "sourceType": "script", - "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 5, - "line": 1, + "column": 15, + "line": 10, }, "start": Object { - "column": 0, - "line": 1, + "column": 14, + "line": 10, }, }, "range": Array [ - 0, - 5, + 166, + 167, ], - "type": "Keyword", - "value": "class", + "type": "Punctuator", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 9, - "line": 1, + "column": 22, + "line": 10, }, "start": Object { - "column": 6, - "line": 1, + "column": 16, + "line": 10, }, }, "range": Array [ - 6, - 9, + 168, + 174, ], "type": "Identifier", - "value": "Foo", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 11, - "line": 1, + "column": 23, + "line": 10, }, "start": Object { - "column": 10, - "line": 1, + "column": 22, + "line": 10, }, }, "range": Array [ - 10, - 11, + 174, + 175, ], "type": "Punctuator", - "value": "{", + "value": ";", }, Object { "loc": Object { "end": Object { - "column": 5, - "line": 2, + "column": 3, + "line": 11, }, "start": Object { "column": 2, - "line": 2, + "line": 11, }, }, "range": Array [ - 14, - 17, + 178, + 179, ], - "type": "Identifier", - "value": "foo", + "type": "Punctuator", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 6, - "line": 2, + "column": 13, + "line": 11, }, "start": Object { - "column": 5, - "line": 2, + "column": 3, + "line": 11, }, }, "range": Array [ - 17, - 18, + 179, + 189, ], - "type": "Punctuator", - "value": "?", + "type": "String", + "value": "'literal2'", }, Object { "loc": Object { "end": Object { - "column": 7, - "line": 2, + "column": 14, + "line": 11, }, "start": Object { - "column": 6, - "line": 2, + "column": 13, + "line": 11, }, }, "range": Array [ - 18, - 19, + 189, + 190, ], "type": "Punctuator", - "value": ";", + "value": "]", }, Object { "loc": Object { "end": Object { - "column": 5, - "line": 3, + "column": 15, + "line": 11, }, "start": Object { - "column": 2, - "line": 3, + "column": 14, + "line": 11, }, }, "range": Array [ - 22, - 25, + 190, + 191, ], - "type": "Identifier", - "value": "bar", + "type": "Punctuator", + "value": "?", }, Object { "loc": Object { "end": Object { - "column": 6, - "line": 3, + "column": 16, + "line": 11, }, "start": Object { - "column": 5, - "line": 3, + "column": 15, + "line": 11, }, }, "range": Array [ - 25, - 26, + 191, + 192, ], "type": "Punctuator", - "value": "?", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 8, - "line": 3, + "column": 23, + "line": 11, }, "start": Object { - "column": 7, - "line": 3, + "column": 17, + "line": 11, }, }, "range": Array [ - 27, - 28, + 193, + 199, ], - "type": "Punctuator", - "value": ":", + "type": "Identifier", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 15, - "line": 3, + "column": 24, + "line": 11, }, "start": Object { - "column": 9, - "line": 3, + "column": 23, + "line": 11, }, }, "range": Array [ - 29, - 35, + 199, + 200, ], - "type": "Identifier", - "value": "string", + "type": "Punctuator", + "value": ";", }, Object { "loc": Object { "end": Object { - "column": 16, - "line": 3, + "column": 3, + "line": 12, }, "start": Object { - "column": 15, - "line": 3, + "column": 2, + "line": 12, }, }, "range": Array [ - 35, - 36, + 203, + 204, ], "type": "Punctuator", - "value": ";", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 9, - "line": 4, + "column": 4, + "line": 12, }, "start": Object { - "column": 2, - "line": 4, + "column": 3, + "line": 12, }, }, "range": Array [ - 39, - 46, + 204, + 205, ], - "type": "Keyword", - "value": "private", + "type": "Numeric", + "value": "2", }, Object { "loc": Object { "end": Object { - "column": 13, - "line": 4, + "column": 5, + "line": 12, }, "start": Object { - "column": 10, - "line": 4, + "column": 4, + "line": 12, }, }, "range": Array [ - 47, - 50, + 205, + 206, ], - "type": "Identifier", - "value": "baz", + "type": "Punctuator", + "value": "]", }, Object { "loc": Object { "end": Object { - "column": 14, - "line": 4, + "column": 6, + "line": 12, }, "start": Object { - "column": 13, - "line": 4, + "column": 5, + "line": 12, }, }, "range": Array [ - 50, - 51, + 206, + 207, ], "type": "Punctuator", "value": "?", @@ -21606,17 +22922,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, - "line": 4, + "column": 7, + "line": 12, }, "start": Object { - "column": 15, - "line": 4, + "column": 6, + "line": 12, }, }, "range": Array [ - 52, - 53, + 207, + 208, ], "type": "Punctuator", "value": ":", @@ -21624,17 +22940,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 23, - "line": 4, + "column": 14, + "line": 12, }, "start": Object { - "column": 17, - "line": 4, + "column": 8, + "line": 12, }, }, "range": Array [ - 54, - 60, + 209, + 215, ], "type": "Identifier", "value": "string", @@ -21642,17 +22958,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 24, - "line": 4, + "column": 15, + "line": 12, }, "start": Object { - "column": 23, - "line": 4, + "column": 14, + "line": 12, }, }, "range": Array [ - 60, - 61, + 215, + 216, ], "type": "Punctuator", "value": ";", @@ -21661,16 +22977,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 13, }, "start": Object { "column": 0, - "line": 5, + "line": 13, }, }, "range": Array [ - 62, - 63, + 217, + 218, ], "type": "Punctuator", "value": "}",