From 625d603f94bf0521f834313bf31c734ce4948b7a Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Sun, 8 Mar 2020 21:00:00 -0700 Subject: [PATCH] feat(typescript-estree): support 3.8 import/export type (#1697) --- .../lib/__snapshots__/typescript.ts.snap | 1068 +++- .../typescript/basics/export-type-as.src.ts | 1 + .../basics/export-type-from-as.src.ts | 1 + .../typescript/basics/export-type-from.src.ts | 1 + .../basics/export-type-star-from.src.ts | 1 + .../typescript/basics/export-type.src.ts | 1 + .../basics/import-type-default.src.ts | 1 + .../basics/import-type-empty.src.ts | 2 + .../basics/import-type-error.src.ts | 1 + .../basics/import-type-named-as.src.ts | 1 + .../basics/import-type-named.src.ts | 1 + .../basics/import-type-star-as-ns.src.ts | 1 + ...s-declaration-export-function-type.src.ts} | 0 ...ias-declaration-export-object-type.src.ts} | 0 ...s => type-alias-declaration-export.src.ts} | 0 ...-type-parameters-in-type-reference.src.ts} | 0 ...rt-type.src.ts => type-import-type.src.ts} | 0 packages/typescript-estree/src/convert.ts | 11 + .../src/ts-estree/ts-estree.ts | 3 + .../tests/ast-alignment/fixtures-to-test.ts | 18 +- .../tests/ast-alignment/utils.ts | 42 + .../lib/__snapshots__/javascript.ts.snap | 42 + .../semantic-diagnostics-enabled.ts.snap | 32 +- .../lib/__snapshots__/semanticInfo.ts.snap | 1 + .../tests/lib/__snapshots__/tsx.ts.snap | 1 + .../lib/__snapshots__/typescript.ts.snap | 5175 +++++++++++++---- 26 files changed, 5193 insertions(+), 1212 deletions(-) create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/export-type-as.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/export-type-from-as.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/export-type-from.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/export-type-star-from.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/export-type.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/import-type-default.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/import-type-empty.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/import-type-error.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/import-type-named-as.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/import-type-named.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/import-type-star-as-ns.src.ts rename packages/shared-fixtures/fixtures/typescript/basics/{export-type-function-declaration.src.ts => type-alias-declaration-export-function-type.src.ts} (100%) rename packages/shared-fixtures/fixtures/typescript/basics/{export-type-class-declaration.src.ts => type-alias-declaration-export-object-type.src.ts} (100%) rename packages/shared-fixtures/fixtures/typescript/basics/{export-type-alias-declaration.src.ts => type-alias-declaration-export.src.ts} (100%) rename packages/shared-fixtures/fixtures/typescript/basics/{import-type-with-type-parameters-in-type-reference.src.ts => type-import-type-with-type-parameters-in-type-reference.src.ts} (100%) rename packages/shared-fixtures/fixtures/typescript/basics/{import-type.src.ts => type-import-type.src.ts} (100%) diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap index e23e1fc4874..9eea694d46d 100644 --- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap @@ -16384,13 +16384,165 @@ Object { } `; -exports[`typescript fixtures/basics/export-type-alias-declaration.src 1`] = ` +exports[`typescript fixtures/basics/export-type.src 1`] = ` +Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 21, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 21, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 0, + "from": Object { + "$ref": 1, + }, + "identifier": Object { + "name": "foo", + "range": Array [ + 14, + 17, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 0, + }, + ], + "type": "module", + "upperScope": Object { + "$ref": 2, + }, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [ + Object { + "$ref": 0, + }, + ], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [], +} +`; + +exports[`typescript fixtures/basics/export-type-as.src 1`] = ` +Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 24, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 24, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 0, + "from": Object { + "$ref": 1, + }, + "identifier": Object { + "name": "A", + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 0, + }, + ], + "type": "module", + "upperScope": Object { + "$ref": 2, + }, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [ + Object { + "$ref": 0, + }, + ], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [], +} +`; + +exports[`typescript fixtures/basics/export-type-from.src 1`] = ` Object { "$id": 1, "block": Object { "range": Array [ 0, - 40, + 32, ], "type": "Program", }, @@ -16400,7 +16552,7 @@ Object { "block": Object { "range": Array [ 0, - 40, + 32, ], "type": "Program", }, @@ -16434,13 +16586,13 @@ Object { } `; -exports[`typescript fixtures/basics/export-type-class-declaration.src 1`] = ` +exports[`typescript fixtures/basics/export-type-from-as.src 1`] = ` Object { "$id": 1, "block": Object { "range": Array [ 0, - 51, + 35, ], "type": "Program", }, @@ -16450,7 +16602,7 @@ Object { "block": Object { "range": Array [ 0, - 51, + 35, ], "type": "Program", }, @@ -16484,13 +16636,13 @@ Object { } `; -exports[`typescript fixtures/basics/export-type-function-declaration.src 1`] = ` +exports[`typescript fixtures/basics/export-type-star-from.src 1`] = ` Object { "$id": 1, "block": Object { "range": Array [ 0, - 47, + 26, ], "type": "Program", }, @@ -16500,7 +16652,7 @@ Object { "block": Object { "range": Array [ 0, - 47, + 26, ], "type": "Program", }, @@ -19443,23 +19595,23 @@ Object { } `; -exports[`typescript fixtures/basics/import-type.src 1`] = ` +exports[`typescript fixtures/basics/import-type-default.src 1`] = ` Object { - "$id": 1, + "$id": 2, "block": Object { "range": Array [ 0, - 56, + 28, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 0, + "$id": 1, "block": Object { "range": Array [ 0, - 56, + 28, ], "type": "Program", }, @@ -19470,13 +19622,64 @@ Object { "throughReferences": Array [], "type": "module", "upperScope": Object { - "$ref": 1, + "$ref": 2, + }, + "variableMap": Object { + "foo": Object { + "$ref": 0, + }, }, - "variableMap": Object {}, "variableScope": Object { - "$ref": 0, + "$ref": 1, }, - "variables": Array [], + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "foo", + "range": Array [ + 12, + 15, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 7, + 15, + ], + "type": "ImportDefaultSpecifier", + }, + "parent": Object { + "range": Array [ + 0, + 27, + ], + "type": "ImportDeclaration", + }, + "type": "ImportBinding", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "foo", + "range": Array [ + 12, + 15, + ], + "type": "Identifier", + }, + ], + "name": "foo", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], }, ], "functionExpressionScope": false, @@ -19487,29 +19690,29 @@ Object { "upperScope": null, "variableMap": Object {}, "variableScope": Object { - "$ref": 1, + "$ref": 2, }, "variables": Array [], } `; -exports[`typescript fixtures/basics/import-type-with-type-parameters-in-type-reference.src 1`] = ` +exports[`typescript fixtures/basics/import-type-empty.src 1`] = ` Object { - "$id": 1, + "$id": 2, "block": Object { "range": Array [ - 0, - 31, + 55, + 81, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 0, + "$id": 1, "block": Object { "range": Array [ - 0, - 31, + 55, + 81, ], "type": "Program", }, @@ -19520,13 +19723,566 @@ Object { "throughReferences": Array [], "type": "module", "upperScope": Object { - "$ref": 1, + "$ref": 2, + }, + "variableMap": Object { + "type": Object { + "$ref": 0, + }, }, - "variableMap": Object {}, "variableScope": Object { - "$ref": 0, + "$ref": 1, }, - "variables": Array [], + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "type", + "range": Array [ + 62, + 66, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 62, + 66, + ], + "type": "ImportDefaultSpecifier", + }, + "parent": Object { + "range": Array [ + 55, + 80, + ], + "type": "ImportDeclaration", + }, + "type": "ImportBinding", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "type", + "range": Array [ + 62, + 66, + ], + "type": "Identifier", + }, + ], + "name": "type", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [], +} +`; + +exports[`typescript fixtures/basics/import-type-error.src 1`] = ` +Object { + "$id": 3, + "block": Object { + "range": Array [ + 0, + 37, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 37, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 3, + }, + "variableMap": Object { + "bar": Object { + "$ref": 1, + }, + "foo": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "foo", + "range": Array [ + 12, + 15, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 7, + 15, + ], + "type": "ImportDefaultSpecifier", + }, + "parent": Object { + "range": Array [ + 0, + 36, + ], + "type": "ImportDeclaration", + }, + "type": "ImportBinding", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "foo", + "range": Array [ + 12, + 15, + ], + "type": "Identifier", + }, + ], + "name": "foo", + "references": Array [], + "scope": Object { + "$ref": 2, + }, + }, + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "bar", + "range": Array [ + 19, + 22, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 19, + 22, + ], + "type": "ImportSpecifier", + }, + "parent": Object { + "range": Array [ + 0, + 36, + ], + "type": "ImportDeclaration", + }, + "type": "ImportBinding", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "bar", + "range": Array [ + 19, + 22, + ], + "type": "Identifier", + }, + ], + "name": "bar", + "references": Array [], + "scope": Object { + "$ref": 2, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 3, + }, + "variables": Array [], +} +`; + +exports[`typescript fixtures/basics/import-type-named.src 1`] = ` +Object { + "$id": 3, + "block": Object { + "range": Array [ + 0, + 37, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 37, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 3, + }, + "variableMap": Object { + "bar": Object { + "$ref": 1, + }, + "foo": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "foo", + "range": Array [ + 14, + 17, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 14, + 17, + ], + "type": "ImportSpecifier", + }, + "parent": Object { + "range": Array [ + 0, + 36, + ], + "type": "ImportDeclaration", + }, + "type": "ImportBinding", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "foo", + "range": Array [ + 14, + 17, + ], + "type": "Identifier", + }, + ], + "name": "foo", + "references": Array [], + "scope": Object { + "$ref": 2, + }, + }, + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "bar", + "range": Array [ + 19, + 22, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 19, + 22, + ], + "type": "ImportSpecifier", + }, + "parent": Object { + "range": Array [ + 0, + 36, + ], + "type": "ImportDeclaration", + }, + "type": "ImportBinding", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "bar", + "range": Array [ + 19, + 22, + ], + "type": "Identifier", + }, + ], + "name": "bar", + "references": Array [], + "scope": Object { + "$ref": 2, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 3, + }, + "variables": Array [], +} +`; + +exports[`typescript fixtures/basics/import-type-named-as.src 1`] = ` +Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 39, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 39, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 2, + }, + "variableMap": Object { + "bar": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "bar", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 14, + 24, + ], + "type": "ImportSpecifier", + }, + "parent": Object { + "range": Array [ + 0, + 38, + ], + "type": "ImportDeclaration", + }, + "type": "ImportBinding", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "bar", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + ], + "name": "bar", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [], +} +`; + +exports[`typescript fixtures/basics/import-type-star-as-ns.src 1`] = ` +Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 35, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 35, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 2, + }, + "variableMap": Object { + "foo": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "foo", + "range": Array [ + 17, + 20, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 12, + 20, + ], + "type": "ImportNamespaceSpecifier", + }, + "parent": Object { + "range": Array [ + 0, + 34, + ], + "type": "ImportDeclaration", + }, + "type": "ImportBinding", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "foo", + "range": Array [ + 17, + 20, + ], + "type": "Identifier", + }, + ], + "name": "foo", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], }, ], "functionExpressionScope": false, @@ -19537,7 +20293,7 @@ Object { "upperScope": null, "variableMap": Object {}, "variableScope": Object { - "$ref": 1, + "$ref": 2, }, "variables": Array [], } @@ -29223,6 +29979,156 @@ Object { } `; +exports[`typescript fixtures/basics/type-alias-declaration-export.src 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 40, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 40, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 1, + }, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [], +} +`; + +exports[`typescript fixtures/basics/type-alias-declaration-export-function-type.src 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 47, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 47, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 1, + }, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [], +} +`; + +exports[`typescript fixtures/basics/type-alias-declaration-export-object-type.src 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 51, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 51, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 1, + }, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [], +} +`; + exports[`typescript fixtures/basics/type-alias-declaration-with-constrained-type-parameter.src 1`] = ` Object { "$id": 1, @@ -31406,6 +32312,106 @@ Object { } `; +exports[`typescript fixtures/basics/type-import-type.src 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 56, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 56, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 1, + }, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [], +} +`; + +exports[`typescript fixtures/basics/type-import-type-with-type-parameters-in-type-reference.src 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 31, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 31, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 1, + }, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [], +} +`; + exports[`typescript fixtures/basics/type-parameters-comments.src 1`] = ` Object { "$id": 8, diff --git a/packages/shared-fixtures/fixtures/typescript/basics/export-type-as.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-type-as.src.ts new file mode 100644 index 00000000000..136f3867f3d --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/export-type-as.src.ts @@ -0,0 +1 @@ +export type { A as B }; diff --git a/packages/shared-fixtures/fixtures/typescript/basics/export-type-from-as.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-type-from-as.src.ts new file mode 100644 index 00000000000..b7c0650b819 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/export-type-from-as.src.ts @@ -0,0 +1 @@ +export type { B as C } from './a'; diff --git a/packages/shared-fixtures/fixtures/typescript/basics/export-type-from.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-type-from.src.ts new file mode 100644 index 00000000000..c0316fd93e2 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/export-type-from.src.ts @@ -0,0 +1 @@ +export type { foo } from 'bar'; diff --git a/packages/shared-fixtures/fixtures/typescript/basics/export-type-star-from.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-type-star-from.src.ts new file mode 100644 index 00000000000..78d72bcf6b7 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/export-type-star-from.src.ts @@ -0,0 +1 @@ +export type * from 'bar'; diff --git a/packages/shared-fixtures/fixtures/typescript/basics/export-type.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-type.src.ts new file mode 100644 index 00000000000..e34ea63759d --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/export-type.src.ts @@ -0,0 +1 @@ +export type { foo }; diff --git a/packages/shared-fixtures/fixtures/typescript/basics/import-type-default.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/import-type-default.src.ts new file mode 100644 index 00000000000..8ac6547e2ab --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/import-type-default.src.ts @@ -0,0 +1 @@ +import type foo from 'bar'; diff --git a/packages/shared-fixtures/fixtures/typescript/basics/import-type-empty.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/import-type-empty.src.ts new file mode 100644 index 00000000000..58067383c44 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/import-type-empty.src.ts @@ -0,0 +1,2 @@ +// this should be treated as a normal import statement +import type from './foo'; diff --git a/packages/shared-fixtures/fixtures/typescript/basics/import-type-error.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/import-type-error.src.ts new file mode 100644 index 00000000000..2a7dc99a0c8 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/import-type-error.src.ts @@ -0,0 +1 @@ +import type foo, { bar } from 'bar'; diff --git a/packages/shared-fixtures/fixtures/typescript/basics/import-type-named-as.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/import-type-named-as.src.ts new file mode 100644 index 00000000000..c7f5ad7e2aa --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/import-type-named-as.src.ts @@ -0,0 +1 @@ +import type { foo as bar } from 'baz'; diff --git a/packages/shared-fixtures/fixtures/typescript/basics/import-type-named.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/import-type-named.src.ts new file mode 100644 index 00000000000..1b58057fb87 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/import-type-named.src.ts @@ -0,0 +1 @@ +import type { foo, bar } from 'baz'; diff --git a/packages/shared-fixtures/fixtures/typescript/basics/import-type-star-as-ns.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/import-type-star-as-ns.src.ts new file mode 100644 index 00000000000..68cd0a8a753 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/import-type-star-as-ns.src.ts @@ -0,0 +1 @@ +import type * as foo from './bar'; diff --git a/packages/shared-fixtures/fixtures/typescript/basics/export-type-function-declaration.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-alias-declaration-export-function-type.src.ts similarity index 100% rename from packages/shared-fixtures/fixtures/typescript/basics/export-type-function-declaration.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/type-alias-declaration-export-function-type.src.ts diff --git a/packages/shared-fixtures/fixtures/typescript/basics/export-type-class-declaration.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-alias-declaration-export-object-type.src.ts similarity index 100% rename from packages/shared-fixtures/fixtures/typescript/basics/export-type-class-declaration.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/type-alias-declaration-export-object-type.src.ts diff --git a/packages/shared-fixtures/fixtures/typescript/basics/export-type-alias-declaration.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-alias-declaration-export.src.ts similarity index 100% rename from packages/shared-fixtures/fixtures/typescript/basics/export-type-alias-declaration.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/type-alias-declaration-export.src.ts diff --git a/packages/shared-fixtures/fixtures/typescript/basics/import-type-with-type-parameters-in-type-reference.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-import-type-with-type-parameters-in-type-reference.src.ts similarity index 100% rename from packages/shared-fixtures/fixtures/typescript/basics/import-type-with-type-parameters-in-type-reference.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/type-import-type-with-type-parameters-in-type-reference.src.ts diff --git a/packages/shared-fixtures/fixtures/typescript/basics/import-type.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-import-type.src.ts similarity index 100% rename from packages/shared-fixtures/fixtures/typescript/basics/import-type.src.ts rename to packages/shared-fixtures/fixtures/typescript/basics/type-import-type.src.ts diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index eb21bdbf2cd..97dc43a5ee2 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -172,11 +172,15 @@ export class Converter { range: [exportKeyword.getStart(this.ast), result.range[1]], }); } else { + const isType = + result.type === AST_NODE_TYPES.TSInterfaceDeclaration || + result.type === AST_NODE_TYPES.TSTypeAliasDeclaration; return this.createNode(node, { type: AST_NODE_TYPES.ExportNamedDeclaration, declaration: result, specifiers: [], source: null, + exportKind: isType ? 'type' : 'value', range: [exportKeyword.getStart(this.ast), result.range[1]], }); } @@ -1529,9 +1533,14 @@ export class Converter { type: AST_NODE_TYPES.ImportDeclaration, source: this.convertChild(node.moduleSpecifier), specifiers: [], + importKind: 'value', }); if (node.importClause) { + if (node.importClause.isTypeOnly) { + result.importKind = 'type'; + } + if (node.importClause.name) { result.specifiers.push(this.convertChild(node.importClause)); } @@ -1587,12 +1596,14 @@ export class Converter { specifiers: node.exportClause.elements.map(el => this.convertChild(el), ), + exportKind: node.isTypeOnly ? 'type' : 'value', declaration: null, }); } else { return this.createNode(node, { type: AST_NODE_TYPES.ExportAllDeclaration, source: this.convertChild(node.moduleSpecifier), + exportKind: node.isTypeOnly ? 'type' : 'value', }); } diff --git a/packages/typescript-estree/src/ts-estree/ts-estree.ts b/packages/typescript-estree/src/ts-estree/ts-estree.ts index 94d4b7c2440..10685a507b9 100644 --- a/packages/typescript-estree/src/ts-estree/ts-estree.ts +++ b/packages/typescript-estree/src/ts-estree/ts-estree.ts @@ -868,6 +868,7 @@ export interface EmptyStatement extends BaseNode { export interface ExportAllDeclaration extends BaseNode { type: AST_NODE_TYPES.ExportAllDeclaration; source: Expression | null; + exportKind: 'type' | 'value'; } export interface ExportDefaultDeclaration extends BaseNode { @@ -880,6 +881,7 @@ export interface ExportNamedDeclaration extends BaseNode { declaration: ExportDeclaration | null; specifiers: ExportSpecifier[]; source: Expression | null; + exportKind: 'type' | 'value'; } export interface ExportSpecifier extends BaseNode { @@ -949,6 +951,7 @@ export interface ImportDeclaration extends BaseNode { type: AST_NODE_TYPES.ImportDeclaration; source: Literal; specifiers: ImportClause[]; + importKind: 'type' | 'value'; } export interface ImportDefaultSpecifier extends BaseNode { diff --git a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts index ab677004678..b970aa38f41 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -379,8 +379,8 @@ tester.addFixturePatternConfig('typescript/basics', { * But not fixed in Babel 7.3 * TODO: Investigate differences */ - 'import-type', - 'import-type-with-type-parameters-in-type-reference', + 'type-import-type', + 'type-import-type-with-type-parameters-in-type-reference', /** * Not yet supported in Babel https://github.com/babel/babel/issues/9228 * Directive field is not added to module and namespace @@ -422,6 +422,20 @@ tester.addFixturePatternConfig('typescript/basics', { */ 'abstract-class-with-declare-properties', 'class-with-declare-properties', + /** + * TS 3.8 import/export type + * babel coming soon https://github.com/babel/babel/pull/11171 + */ + 'export-type-as', + 'export-type-from-as', + 'export-type-from', + 'export-type-star-from', + 'export-type', + 'import-type-default', + 'import-type-error', + 'import-type-named-as', + 'import-type-named', + 'import-type-star-as-ns', ], ignoreSourceType: [ /** diff --git a/packages/typescript-estree/tests/ast-alignment/utils.ts b/packages/typescript-estree/tests/ast-alignment/utils.ts index 002a4c66dcb..6a2426b147f 100644 --- a/packages/typescript-estree/tests/ast-alignment/utils.ts +++ b/packages/typescript-estree/tests/ast-alignment/utils.ts @@ -248,6 +248,48 @@ export function preprocessBabylonAST(ast: BabelTypes.File): any { node.asserts = false; } }, + /** + * TS 3.8 import/export type + * babel coming soon https://github.com/babel/babel/pull/11171 + */ + ExportNamedDeclaration(node: any) { + /** + * TS 3.8: export type + */ + if (!node.exportKind) { + if ( + node.declaration?.type === AST_NODE_TYPES.TSTypeAliasDeclaration || + node.declaration?.type === AST_NODE_TYPES.TSInterfaceDeclaration + ) { + node.exportKind = 'type'; + } else { + node.exportKind = 'value'; + } + } + }, + ExportAllDeclaration(node: any) { + /** + * TS 3.8: export type + */ + if (!node.exportKind) { + if ( + node.declaration?.type === AST_NODE_TYPES.TSTypeAliasDeclaration || + node.declaration?.type === AST_NODE_TYPES.TSInterfaceDeclaration + ) { + node.exportKind = 'type'; + } else { + node.exportKind = 'value'; + } + } + }, + ImportDeclaration(node) { + /** + * TS 3.8: export type + */ + if (!node.importKind) { + node.importKind = 'value'; + } + }, }, ); } diff --git a/packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap index 0f9639a3bcb..ef4ac4c58c1 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/javascript.ts.snap @@ -108235,6 +108235,7 @@ exports[`javascript fixtures/modules/error-delete.src 1`] = ` Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 18, @@ -108829,6 +108830,7 @@ exports[`javascript fixtures/modules/error-strict.src 1`] = ` Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 26, @@ -109472,6 +109474,7 @@ Object { ], "type": "FunctionDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 30, @@ -109734,6 +109737,7 @@ Object { ], "type": "VariableDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 21, @@ -111891,6 +111895,7 @@ exports[`javascript fixtures/modules/export-from-batch.src 1`] = ` Object { "body": Array [ Object { + "exportKind": "value", "loc": Object { "end": Object { "column": 20, @@ -112043,6 +112048,7 @@ Object { "body": Array [ Object { "declaration": null, + "exportKind": "value", "loc": Object { "end": Object { "column": 28, @@ -112286,6 +112292,7 @@ Object { "body": Array [ Object { "declaration": null, + "exportKind": "value", "loc": Object { "end": Object { "column": 35, @@ -112565,6 +112572,7 @@ Object { "body": Array [ Object { "declaration": null, + "exportKind": "value", "loc": Object { "end": Object { "column": 31, @@ -112844,6 +112852,7 @@ Object { "body": Array [ Object { "declaration": null, + "exportKind": "value", "loc": Object { "end": Object { "column": 40, @@ -113212,6 +113221,7 @@ Object { "body": Array [ Object { "declaration": null, + "exportKind": "value", "loc": Object { "end": Object { "column": 24, @@ -113455,6 +113465,7 @@ Object { "body": Array [ Object { "declaration": null, + "exportKind": "value", "loc": Object { "end": Object { "column": 29, @@ -113843,6 +113854,7 @@ Object { ], "type": "FunctionDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 25, @@ -114087,6 +114099,7 @@ Object { ], "type": "VariableDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 19, @@ -114240,6 +114253,7 @@ Object { "body": Array [ Object { "declaration": null, + "exportKind": "value", "loc": Object { "end": Object { "column": 24, @@ -114465,6 +114479,7 @@ Object { "body": Array [ Object { "declaration": null, + "exportKind": "value", "loc": Object { "end": Object { "column": 20, @@ -114690,6 +114705,7 @@ Object { "body": Array [ Object { "declaration": null, + "exportKind": "value", "loc": Object { "end": Object { "column": 29, @@ -115057,6 +115073,7 @@ Object { "superClass": null, "type": "ClassDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 1, @@ -115192,6 +115209,7 @@ Object { "body": Array [ Object { "declaration": null, + "exportKind": "value", "loc": Object { "end": Object { "column": 10, @@ -115309,6 +115327,7 @@ Object { "body": Array [ Object { "declaration": null, + "exportKind": "value", "loc": Object { "end": Object { "column": 13, @@ -115498,6 +115517,7 @@ Object { "body": Array [ Object { "declaration": null, + "exportKind": "value", "loc": Object { "end": Object { "column": 18, @@ -115776,6 +115796,7 @@ Object { "body": Array [ Object { "declaration": null, + "exportKind": "value", "loc": Object { "end": Object { "column": 19, @@ -116127,6 +116148,7 @@ Object { ], "type": "VariableDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 15, @@ -116338,6 +116360,7 @@ Object { ], "type": "VariableDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 32, @@ -116636,6 +116659,7 @@ Object { ], "type": "VariableDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 19, @@ -116788,6 +116812,7 @@ exports[`javascript fixtures/modules/import-default.src 1`] = ` Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 22, @@ -116976,6 +117001,7 @@ exports[`javascript fixtures/modules/import-default-and-named-specifiers.src 1`] Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 29, @@ -117289,6 +117315,7 @@ exports[`javascript fixtures/modules/import-default-and-namespace-specifiers.src Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 32, @@ -117584,6 +117611,7 @@ exports[`javascript fixtures/modules/import-default-as.src 1`] = ` Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 35, @@ -117862,6 +117890,7 @@ exports[`javascript fixtures/modules/import-jquery.src 1`] = ` Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 22, @@ -118032,6 +118061,7 @@ exports[`javascript fixtures/modules/import-module.src 1`] = ` Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 13, @@ -118148,6 +118178,7 @@ exports[`javascript fixtures/modules/import-named-as-specifier.src 1`] = ` Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 31, @@ -118426,6 +118457,7 @@ exports[`javascript fixtures/modules/import-named-as-specifiers.src 1`] = ` Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 36, @@ -118793,6 +118825,7 @@ exports[`javascript fixtures/modules/import-named-empty.src 1`] = ` Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 21, @@ -118963,6 +118996,7 @@ exports[`javascript fixtures/modules/import-named-specifier.src 1`] = ` Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 24, @@ -119205,6 +119239,7 @@ exports[`javascript fixtures/modules/import-named-specifiers.src 1`] = ` Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 29, @@ -119536,6 +119571,7 @@ exports[`javascript fixtures/modules/import-named-specifiers-comma.src 1`] = ` Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 30, @@ -119885,6 +119921,7 @@ exports[`javascript fixtures/modules/import-namespace-specifier.src 1`] = ` Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 27, @@ -120109,6 +120146,7 @@ exports[`javascript fixtures/modules/import-null-as-nil.src 1`] = ` Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 33, @@ -120425,6 +120463,7 @@ Object { ], "type": "VariableDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 17, @@ -120721,6 +120760,7 @@ Object { "body": Array [ Object { "declaration": null, + "exportKind": "value", "loc": Object { "end": Object { "column": 16, @@ -120903,6 +120943,7 @@ exports[`javascript fixtures/modules/invalid-import-default-module-specifier.src Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 20, @@ -121093,6 +121134,7 @@ Object { "body": Array [ Object { "declaration": null, + "exportKind": "value", "loc": Object { "end": Object { "column": 21, diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap index e1c91feca7f..f3189765268 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap @@ -1878,11 +1878,15 @@ Object { } `; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-type-alias-declaration.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-type.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-type-class-declaration.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-type-as.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-type-function-declaration.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-type-from.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-type-from-as.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-type-star-from.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/function-anonymus-with-type-parameters.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; @@ -1912,9 +1916,17 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/import-export-equal-declaration.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/import-type.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/import-type-default.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/import-type-empty.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/import-type-error.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/import-type-named.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/import-type-named-as.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; -exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/import-type-with-type-parameters-in-type-reference.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/import-type-star-as-ns.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/interface-extends.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; @@ -1996,6 +2008,12 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/type-alias-declaration.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/type-alias-declaration-export.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/type-alias-declaration-export-function-type.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/type-alias-declaration-export-object-type.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/type-alias-declaration-with-constrained-type-parameter.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/type-alias-object-without-annotation.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; @@ -2024,6 +2042,10 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/type-guard-in-method.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/type-import-type.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/type-import-type-with-type-parameters-in-type-reference.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/type-parameters-comments.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/type-parameters-comments-heritage.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semanticInfo.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semanticInfo.ts.snap index f6b67ce5556..feb0d60b462 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semanticInfo.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semanticInfo.ts.snap @@ -303,6 +303,7 @@ exports[`semanticInfo fixtures/import-file.src 1`] = ` Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 36, diff --git a/packages/typescript-estree/tests/lib/__snapshots__/tsx.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/tsx.ts.snap index 84558c7e0a6..1cda86868dc 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/tsx.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/tsx.ts.snap @@ -938,6 +938,7 @@ exports[`TSX fixtures/react-typed-props.src 1`] = ` Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 30, diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap index cbd1e12b378..dc2275c4cd3 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap @@ -823,6 +823,7 @@ Object { "superClass": null, "type": "ClassDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 1, @@ -1270,6 +1271,7 @@ Object { "superClass": null, "type": "ClassDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 1, @@ -2486,6 +2488,7 @@ Object { "superClass": null, "type": "ClassDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 1, @@ -4086,6 +4089,7 @@ Object { "superClass": null, "type": "ClassDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 1, @@ -4472,6 +4476,7 @@ Object { ], "type": "TSInterfaceDeclaration", }, + "exportKind": "type", "loc": Object { "end": Object { "column": 1, @@ -43714,6 +43719,7 @@ Object { ], "type": "TSEnumDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 1, @@ -44101,6 +44107,7 @@ Object { ], "type": "TSEnumDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 1, @@ -45076,6 +45083,7 @@ Object { "type": "TSTypeParameterDeclaration", }, }, + "exportKind": "value", "loc": Object { "end": Object { "column": 1, @@ -45407,6 +45415,7 @@ Object { "type": "TSTypeParameterDeclaration", }, }, + "exportKind": "value", "loc": Object { "end": Object { "column": 1, @@ -45757,6 +45766,7 @@ Object { ], "type": "TSEnumDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 1, @@ -46055,6 +46065,7 @@ Object { ], "type": "TSEnumDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 1, @@ -46335,6 +46346,7 @@ Object { ], "type": "TSEnumDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 1, @@ -46614,6 +46626,7 @@ Object { ], "type": "TSEnumDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 1, @@ -46816,101 +46829,223 @@ Object { } `; -exports[`typescript fixtures/basics/export-type-alias-declaration.src 1`] = ` +exports[`typescript fixtures/basics/export-type.src 1`] = ` Object { "body": Array [ Object { - "declaration": Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, - }, - "name": "TestAlias", - "range": Array [ - 12, - 21, - ], - "type": "Identifier", + "declaration": null, + "exportKind": "type", + "loc": Object { + "end": Object { + "column": 20, + "line": 1, }, - "loc": Object { - "end": Object { - "column": 40, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, + "start": Object { + "column": 0, + "line": 1, }, - "range": Array [ - 7, - 40, - ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { + }, + "range": Array [ + 0, + 20, + ], + "source": null, + "specifiers": Array [ + Object { + "exported": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 14, + 17, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 39, + "column": 17, "line": 1, }, "start": Object { - "column": 24, + "column": 14, "line": 1, }, }, - "range": Array [ - 24, - 39, - ], - "type": "TSUnionType", - "types": Array [ - Object { - "loc": Object { - "end": Object { - "column": 30, - "line": 1, - }, - "start": Object { - "column": 24, - "line": 1, - }, + "local": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, }, - "range": Array [ - 24, - 30, - ], - "type": "TSStringKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 39, - "line": 1, - }, - "start": Object { - "column": 33, - "line": 1, - }, + "start": Object { + "column": 14, + "line": 1, }, - "range": Array [ - 33, - 39, - ], - "type": "TSNumberKeyword", }, + "name": "foo", + "range": Array [ + 14, + 17, + ], + "type": "Identifier", + }, + "range": Array [ + 14, + 17, ], + "type": "ExportSpecifier", + }, + ], + "type": "ExportNamedDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 21, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, }, }, + "range": Array [ + 7, + 11, + ], + "type": "Identifier", + "value": "type", + }, + Object { "loc": Object { "end": Object { - "column": 40, + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 17, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/export-type-as.src 1`] = ` +Object { + "body": Array [ + Object { + "declaration": null, + "exportKind": "type", + "loc": Object { + "end": Object { + "column": 23, "line": 1, }, "start": Object { @@ -46920,17 +47055,71 @@ Object { }, "range": Array [ 0, - 40, + 23, ], "source": null, - "specifiers": Array [], + "specifiers": Array [ + Object { + "exported": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "name": "B", + "range": Array [ + 19, + 20, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "local": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "name": "A", + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + }, + "range": Array [ + 14, + 20, + ], + "type": "ExportSpecifier", + }, + ], "type": "ExportNamedDeclaration", }, ], "loc": Object { "end": Object { - "column": 40, - "line": 1, + "column": 0, + "line": 2, }, "start": Object { "column": 0, @@ -46939,7 +47128,7 @@ Object { }, "range": Array [ 0, - 40, + 24, ], "sourceType": "module", "tokens": Array [ @@ -46982,7 +47171,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 21, + "column": 13, "line": 1, }, "start": Object { @@ -46992,97 +47181,97 @@ Object { }, "range": Array [ 12, - 21, + 13, ], - "type": "Identifier", - "value": "TestAlias", + "type": "Punctuator", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 23, + "column": 15, "line": 1, }, "start": Object { - "column": 22, + "column": 14, "line": 1, }, }, "range": Array [ - 22, - 23, + 14, + 15, ], - "type": "Punctuator", - "value": "=", + "type": "Identifier", + "value": "A", }, Object { "loc": Object { "end": Object { - "column": 30, + "column": 18, "line": 1, }, "start": Object { - "column": 24, + "column": 16, "line": 1, }, }, "range": Array [ - 24, - 30, + 16, + 18, ], "type": "Identifier", - "value": "string", + "value": "as", }, Object { "loc": Object { "end": Object { - "column": 32, + "column": 20, "line": 1, }, "start": Object { - "column": 31, + "column": 19, "line": 1, }, }, "range": Array [ - 31, - 32, + 19, + 20, ], - "type": "Punctuator", - "value": "|", + "type": "Identifier", + "value": "B", }, Object { "loc": Object { "end": Object { - "column": 39, + "column": 22, "line": 1, }, "start": Object { - "column": 33, + "column": 21, "line": 1, }, }, "range": Array [ - 33, - 39, + 21, + 22, ], - "type": "Identifier", - "value": "number", + "type": "Punctuator", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 40, + "column": 23, "line": 1, }, "start": Object { - "column": 39, + "column": 22, "line": 1, }, }, "range": Array [ - 39, - 40, + 22, + 23, ], "type": "Punctuator", "value": ";", @@ -47092,157 +47281,107 @@ Object { } `; -exports[`typescript fixtures/basics/export-type-class-declaration.src 1`] = ` +exports[`typescript fixtures/basics/export-type-from.src 1`] = ` Object { "body": Array [ Object { - "declaration": Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 26, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, - }, - "name": "TestClassProps", - "range": Array [ - 12, - 26, - ], - "type": "Identifier", + "declaration": null, + "exportKind": "type", + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, }, + }, + "range": Array [ + 0, + 31, + ], + "source": Object { "loc": Object { "end": Object { - "column": 2, - "line": 3, + "column": 30, + "line": 1, }, "start": Object { - "column": 7, + "column": 25, "line": 1, }, }, "range": Array [ - 7, - 51, + 25, + 30, ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { + "raw": "'bar'", + "type": "Literal", + "value": "bar", + }, + "specifiers": Array [ + Object { + "exported": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 14, + 17, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 1, - "line": 3, + "column": 17, + "line": 1, }, "start": Object { - "column": 29, + "column": 14, "line": 1, }, }, - "members": Array [ - Object { - "computed": false, - "key": Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 2, - }, - "start": Object { - "column": 4, - "line": 2, - }, - }, - "name": "count", - "range": Array [ - 35, - 40, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 4, - "line": 2, - }, + "local": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, }, - "range": Array [ - 35, - 48, - ], - "type": "TSPropertySignature", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 9, - "line": 2, - }, - }, - "range": Array [ - 40, - 48, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 11, - "line": 2, - }, - }, - "range": Array [ - 42, - 48, - ], - "type": "TSNumberKeyword", - }, + "start": Object { + "column": 14, + "line": 1, }, }, - ], + "name": "foo", + "range": Array [ + 14, + 17, + ], + "type": "Identifier", + }, "range": Array [ - 29, - 50, + 14, + 17, ], - "type": "TSTypeLiteral", - }, - }, - "loc": Object { - "end": Object { - "column": 2, - "line": 3, - }, - "start": Object { - "column": 0, - "line": 1, + "type": "ExportSpecifier", }, - }, - "range": Array [ - 0, - 51, ], - "source": null, - "specifiers": Array [], "type": "ExportNamedDeclaration", }, ], "loc": Object { "end": Object { - "column": 2, - "line": 3, + "column": 0, + "line": 2, }, "start": Object { "column": 0, @@ -47251,7 +47390,7 @@ Object { }, "range": Array [ 0, - 51, + 32, ], "sourceType": "module", "tokens": Array [ @@ -47294,7 +47433,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 26, + "column": 13, "line": 1, }, "start": Object { @@ -47304,133 +47443,97 @@ Object { }, "range": Array [ 12, - 26, - ], - "type": "Identifier", - "value": "TestClassProps", - }, - Object { - "loc": Object { - "end": Object { - "column": 28, - "line": 1, - }, - "start": Object { - "column": 27, - "line": 1, - }, - }, - "range": Array [ - 27, - 28, + 13, ], "type": "Punctuator", - "value": "=", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 30, + "column": 17, "line": 1, }, "start": Object { - "column": 29, + "column": 14, "line": 1, }, }, "range": Array [ - 29, - 30, - ], - "type": "Punctuator", - "value": "{", - }, - Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 2, - }, - "start": Object { - "column": 4, - "line": 2, - }, - }, - "range": Array [ - 35, - 40, + 14, + 17, ], "type": "Identifier", - "value": "count", + "value": "foo", }, Object { "loc": Object { "end": Object { - "column": 10, - "line": 2, + "column": 19, + "line": 1, }, "start": Object { - "column": 9, - "line": 2, + "column": 18, + "line": 1, }, }, "range": Array [ - 40, - 41, + 18, + 19, ], "type": "Punctuator", - "value": ":", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 17, - "line": 2, + "column": 24, + "line": 1, }, "start": Object { - "column": 11, - "line": 2, + "column": 20, + "line": 1, }, }, "range": Array [ - 42, - 48, + 20, + 24, ], "type": "Identifier", - "value": "number", + "value": "from", }, Object { "loc": Object { "end": Object { - "column": 1, - "line": 3, + "column": 30, + "line": 1, }, "start": Object { - "column": 0, - "line": 3, + "column": 25, + "line": 1, }, }, "range": Array [ - 49, - 50, + 25, + 30, ], - "type": "Punctuator", - "value": "}", + "type": "String", + "value": "'bar'", }, Object { "loc": Object { "end": Object { - "column": 2, - "line": 3, + "column": 31, + "line": 1, }, "start": Object { - "column": 1, - "line": 3, + "column": 30, + "line": 1, }, }, "range": Array [ - 50, - 51, + 30, + 31, ], "type": "Punctuator", "value": ";", @@ -47440,173 +47543,107 @@ Object { } `; -exports[`typescript fixtures/basics/export-type-function-declaration.src 1`] = ` +exports[`typescript fixtures/basics/export-type-from-as.src 1`] = ` Object { "body": Array [ Object { - "declaration": Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, - }, - "name": "TestCallback", - "range": Array [ - 12, - 24, - ], - "type": "Identifier", + "declaration": null, + "exportKind": "type", + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, }, + }, + "range": Array [ + 0, + 34, + ], + "source": Object { "loc": Object { "end": Object { - "column": 47, + "column": 33, "line": 1, }, "start": Object { - "column": 7, + "column": 28, "line": 1, }, }, "range": Array [ - 7, - 47, + 28, + 33, ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { + "raw": "'./a'", + "type": "Literal", + "value": "./a", + }, + "specifiers": Array [ + Object { + "exported": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "name": "C", + "range": Array [ + 19, + 20, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 46, + "column": 20, "line": 1, }, "start": Object { - "column": 27, + "column": 14, "line": 1, }, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 37, - "line": 1, - }, - "start": Object { - "column": 28, - "line": 1, - }, - }, - "name": "a", - "range": Array [ - 28, - 37, - ], - "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 37, - "line": 1, - }, - "start": Object { - "column": 29, - "line": 1, - }, - }, - "range": Array [ - 29, - 37, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 37, - "line": 1, - }, - "start": Object { - "column": 31, - "line": 1, - }, - }, - "range": Array [ - 31, - 37, - ], - "type": "TSNumberKeyword", - }, - }, - }, - ], - "range": Array [ - 27, - 46, - ], - "returnType": Object { + "local": Object { "loc": Object { "end": Object { - "column": 46, + "column": 15, "line": 1, }, "start": Object { - "column": 39, + "column": 14, "line": 1, }, }, + "name": "B", "range": Array [ - 39, - 46, + 14, + 15, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 46, - "line": 1, - }, - "start": Object { - "column": 42, - "line": 1, - }, - }, - "range": Array [ - 42, - 46, - ], - "type": "TSVoidKeyword", - }, + "type": "Identifier", }, - "type": "TSFunctionType", - }, - }, - "loc": Object { - "end": Object { - "column": 47, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, + "range": Array [ + 14, + 20, + ], + "type": "ExportSpecifier", }, - }, - "range": Array [ - 0, - 47, ], - "source": null, - "specifiers": Array [], "type": "ExportNamedDeclaration", }, ], "loc": Object { "end": Object { - "column": 47, - "line": 1, + "column": 0, + "line": 2, }, "start": Object { "column": 0, @@ -47615,7 +47652,7 @@ Object { }, "range": Array [ 0, - 47, + 35, ], "sourceType": "module", "tokens": Array [ @@ -47658,7 +47695,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 24, + "column": 13, "line": 1, }, "start": Object { @@ -47668,181 +47705,315 @@ Object { }, "range": Array [ 12, - 24, + 13, ], - "type": "Identifier", - "value": "TestCallback", + "type": "Punctuator", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 26, + "column": 15, "line": 1, }, "start": Object { - "column": 25, + "column": 14, "line": 1, }, }, "range": Array [ - 25, - 26, + 14, + 15, ], - "type": "Punctuator", - "value": "=", + "type": "Identifier", + "value": "B", }, Object { "loc": Object { "end": Object { - "column": 28, + "column": 18, "line": 1, }, "start": Object { - "column": 27, + "column": 16, "line": 1, }, }, "range": Array [ - 27, - 28, + 16, + 18, ], - "type": "Punctuator", - "value": "(", + "type": "Identifier", + "value": "as", }, Object { "loc": Object { "end": Object { - "column": 29, + "column": 20, "line": 1, }, "start": Object { - "column": 28, + "column": 19, "line": 1, }, }, "range": Array [ - 28, - 29, + 19, + 20, ], "type": "Identifier", - "value": "a", + "value": "C", }, Object { "loc": Object { "end": Object { - "column": 30, + "column": 22, "line": 1, }, "start": Object { - "column": 29, + "column": 21, "line": 1, }, }, "range": Array [ - 29, - 30, + 21, + 22, ], "type": "Punctuator", - "value": ":", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 37, + "column": 27, "line": 1, }, "start": Object { - "column": 31, + "column": 23, "line": 1, }, }, "range": Array [ - 31, - 37, + 23, + 27, ], "type": "Identifier", - "value": "number", + "value": "from", }, Object { "loc": Object { "end": Object { - "column": 38, + "column": 33, "line": 1, }, "start": Object { - "column": 37, + "column": 28, "line": 1, }, }, "range": Array [ - 37, - 38, + 28, + 33, ], - "type": "Punctuator", - "value": ")", + "type": "String", + "value": "'./a'", }, Object { "loc": Object { "end": Object { - "column": 41, + "column": 34, "line": 1, }, "start": Object { - "column": 39, + "column": 33, "line": 1, }, }, "range": Array [ - 39, - 41, + 33, + 34, ], "type": "Punctuator", - "value": "=>", + "value": ";", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/export-type-star-from.src 1`] = ` +Object { + "body": Array [ Object { + "exportKind": "type", "loc": Object { "end": Object { - "column": 46, + "column": 25, "line": 1, }, "start": Object { - "column": 42, + "column": 0, "line": 1, }, }, "range": Array [ - 42, - 46, + 0, + 25, + ], + "source": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 24, + ], + "raw": "'bar'", + "type": "Literal", + "value": "bar", + }, + "type": "ExportAllDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 26, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, ], "type": "Keyword", - "value": "void", + "value": "export", }, Object { "loc": Object { "end": Object { - "column": 47, + "column": 11, "line": 1, }, "start": Object { - "column": 46, + "column": 7, "line": 1, }, }, "range": Array [ - 46, - 47, + 7, + 11, ], - "type": "Punctuator", - "value": ";", + "type": "Identifier", + "value": "type", }, - ], - "type": "Program", -} -`; - -exports[`typescript fixtures/basics/function-anonymus-with-type-parameters.src 1`] = ` -Object { - "body": Array [ + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": "*", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 18, + ], + "type": "Identifier", + "value": "from", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 24, + ], + "type": "String", + "value": "'bar'", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 25, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/function-anonymus-with-type-parameters.src 1`] = ` +Object { + "body": Array [ Object { "declarations": Array [ Object { @@ -48909,6 +49080,7 @@ Object { }, "type": "TSDeclareFunction", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 37, @@ -49054,6 +49226,7 @@ Object { }, "type": "TSDeclareFunction", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 37, @@ -49325,6 +49498,7 @@ Object { }, "type": "FunctionDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 1, @@ -56129,31 +56303,14 @@ Object { } `; -exports[`typescript fixtures/basics/import-type.src 1`] = ` +exports[`typescript fixtures/basics/import-type-default.src 1`] = ` Object { "body": Array [ Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 6, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, - }, - "name": "A", - "range": Array [ - 5, - 6, - ], - "type": "Identifier", - }, + "importKind": "type", "loc": Object { "end": Object { - "column": 28, + "column": 27, "line": 1, }, "start": Object { @@ -56163,232 +56320,71 @@ Object { }, "range": Array [ 0, - 28, + 27, ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { - "isTypeOf": true, + "source": Object { "loc": Object { "end": Object { - "column": 27, + "column": 26, "line": 1, }, "start": Object { - "column": 9, + "column": 21, "line": 1, }, }, - "parameter": Object { - "literal": Object { - "loc": Object { - "end": Object { - "column": 26, - "line": 1, - }, - "start": Object { - "column": 23, - "line": 1, - }, - }, - "range": Array [ - 23, - 26, - ], - "raw": "'A'", - "type": "Literal", - "value": "A", - }, + "range": Array [ + 21, + 26, + ], + "raw": "'bar'", + "type": "Literal", + "value": "bar", + }, + "specifiers": Array [ + Object { "loc": Object { "end": Object { - "column": 26, + "column": 15, "line": 1, }, "start": Object { - "column": 23, + "column": 7, "line": 1, }, }, - "range": Array [ - 23, - 26, - ], - "type": "TSLiteralType", - }, - "qualifier": null, - "range": Array [ - 9, - 27, - ], - "type": "TSImportType", - "typeParameters": null, - }, - }, - Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 6, - "line": 2, - }, - "start": Object { - "column": 5, - "line": 2, - }, - }, - "name": "B", - "range": Array [ - 34, - 35, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 26, - "line": 2, - }, - "start": Object { - "column": 0, - "line": 2, - }, - }, - "range": Array [ - 29, - 55, - ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { - "isTypeOf": false, - "loc": Object { - "end": Object { - "column": 25, - "line": 2, - }, - "start": Object { - "column": 9, - "line": 2, - }, - }, - "parameter": Object { - "literal": Object { + "local": Object { "loc": Object { "end": Object { - "column": 19, - "line": 2, + "column": 15, + "line": 1, }, "start": Object { - "column": 16, - "line": 2, + "column": 12, + "line": 1, }, }, + "name": "foo", "range": Array [ - 45, - 48, + 12, + 15, ], - "raw": "\\"B\\"", - "type": "Literal", - "value": "B", - }, - "loc": Object { - "end": Object { - "column": 19, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "range": Array [ - 45, - 48, - ], - "type": "TSLiteralType", - }, - "qualifier": Object { - "loc": Object { - "end": Object { - "column": 22, - "line": 2, - }, - "start": Object { - "column": 21, - "line": 2, - }, - }, - "name": "X", - "range": Array [ - 50, - 51, - ], - "type": "Identifier", - }, - "range": Array [ - 38, - 54, - ], - "type": "TSImportType", - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 25, - "line": 2, - }, - "start": Object { - "column": 22, - "line": 2, - }, + "type": "Identifier", }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 2, - }, - "start": Object { - "column": 23, - "line": 2, - }, - }, - "range": Array [ - 52, - 53, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 2, - }, - "start": Object { - "column": 23, - "line": 2, - }, - }, - "name": "Y", - "range": Array [ - 52, - 53, - ], - "type": "Identifier", - }, - }, - ], "range": Array [ - 51, - 54, + 7, + 15, ], - "type": "TSTypeParameterInstantiation", + "type": "ImportDefaultSpecifier", }, - }, + ], + "type": "ImportDeclaration", }, ], "loc": Object { "end": Object { "column": 0, - "line": 3, + "line": 2, }, "start": Object { "column": 0, @@ -56397,14 +56393,14 @@ Object { }, "range": Array [ 0, - 56, + 28, ], - "sourceType": "script", + "sourceType": "module", "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 4, + "column": 6, "line": 1, }, "start": Object { @@ -56414,33 +56410,15 @@ Object { }, "range": Array [ 0, - 4, - ], - "type": "Identifier", - "value": "type", - }, - Object { - "loc": Object { - "end": Object { - "column": 6, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, - }, - "range": Array [ - 5, 6, ], - "type": "Identifier", - "value": "A", + "type": "Keyword", + "value": "import", }, Object { "loc": Object { "end": Object { - "column": 8, + "column": 11, "line": 1, }, "start": Object { @@ -56450,10 +56428,10 @@ Object { }, "range": Array [ 7, - 8, + 11, ], - "type": "Punctuator", - "value": "=", + "type": "Identifier", + "value": "type", }, Object { "loc": Object { @@ -56462,21 +56440,21 @@ Object { "line": 1, }, "start": Object { - "column": 9, + "column": 12, "line": 1, }, }, "range": Array [ - 9, + 12, 15, ], - "type": "Keyword", - "value": "typeof", + "type": "Identifier", + "value": "foo", }, Object { "loc": Object { "end": Object { - "column": 22, + "column": 20, "line": 1, }, "start": Object { @@ -56486,28 +56464,10 @@ Object { }, "range": Array [ 16, - 22, - ], - "type": "Keyword", - "value": "import", - }, - Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 1, - }, - "start": Object { - "column": 22, - "line": 1, - }, - }, - "range": Array [ - 22, - 23, + 20, ], - "type": "Punctuator", - "value": "(", + "type": "Identifier", + "value": "from", }, Object { "loc": Object { @@ -56516,16 +56476,16 @@ Object { "line": 1, }, "start": Object { - "column": 23, + "column": 21, "line": 1, }, }, "range": Array [ - 23, + 21, 26, ], "type": "String", - "value": "'A'", + "value": "'bar'", }, Object { "loc": Object { @@ -56543,30 +56503,21 @@ Object { 27, ], "type": "Punctuator", - "value": ")", - }, - Object { - "loc": Object { - "end": Object { - "column": 28, - "line": 1, - }, - "start": Object { - "column": 27, - "line": 1, - }, - }, - "range": Array [ - 27, - 28, - ], - "type": "Punctuator", "value": ";", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/import-type-empty.src 1`] = ` +Object { + "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { - "column": 4, + "column": 25, "line": 2, }, "start": Object { @@ -56575,62 +56526,98 @@ Object { }, }, "range": Array [ - 29, - 33, + 55, + 80, ], - "type": "Identifier", - "value": "type", - }, - Object { - "loc": Object { - "end": Object { - "column": 6, - "line": 2, - }, - "start": Object { - "column": 5, - "line": 2, + "source": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, }, + "range": Array [ + 72, + 79, + ], + "raw": "'./foo'", + "type": "Literal", + "value": "./foo", }, - "range": Array [ - 34, - 35, - ], - "type": "Identifier", - "value": "B", - }, - Object { - "loc": Object { - "end": Object { - "column": 8, - "line": 2, - }, - "start": Object { - "column": 7, - "line": 2, + "specifiers": Array [ + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "local": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "name": "type", + "range": Array [ + 62, + 66, + ], + "type": "Identifier", + }, + "range": Array [ + 62, + 66, + ], + "type": "ImportDefaultSpecifier", }, - }, - "range": Array [ - 36, - 37, ], - "type": "Punctuator", - "value": "=", + "type": "ImportDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 2, }, + }, + "range": Array [ + 55, + 81, + ], + "sourceType": "module", + "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 15, + "column": 6, "line": 2, }, "start": Object { - "column": 9, + "column": 0, "line": 2, }, }, "range": Array [ - 38, - 44, + 55, + 61, ], "type": "Keyword", "value": "import", @@ -56638,110 +56625,38 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, + "column": 11, "line": 2, }, "start": Object { - "column": 15, + "column": 7, "line": 2, }, }, "range": Array [ - 44, - 45, + 62, + 66, ], - "type": "Punctuator", - "value": "(", + "type": "Identifier", + "value": "type", }, Object { "loc": Object { "end": Object { - "column": 19, - "line": 2, - }, - "start": Object { "column": 16, "line": 2, }, - }, - "range": Array [ - 45, - 48, - ], - "type": "String", - "value": "\\"B\\"", - }, - Object { - "loc": Object { - "end": Object { - "column": 20, - "line": 2, - }, - "start": Object { - "column": 19, - "line": 2, - }, - }, - "range": Array [ - 48, - 49, - ], - "type": "Punctuator", - "value": ")", - }, - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 2, - }, - "start": Object { - "column": 20, - "line": 2, - }, - }, - "range": Array [ - 49, - 50, - ], - "type": "Punctuator", - "value": ".", - }, - Object { - "loc": Object { - "end": Object { - "column": 22, - "line": 2, - }, "start": Object { - "column": 21, + "column": 12, "line": 2, }, }, "range": Array [ - 50, - 51, + 67, + 71, ], "type": "Identifier", - "value": "X", - }, - Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 2, - }, - "start": Object { - "column": 22, - "line": 2, - }, - }, - "range": Array [ - 51, - 52, - ], - "type": "Punctuator", - "value": "<", + "value": "from", }, Object { "loc": Object { @@ -56750,16 +56665,16 @@ Object { "line": 2, }, "start": Object { - "column": 23, + "column": 17, "line": 2, }, }, "range": Array [ - 52, - 53, + 72, + 79, ], - "type": "Identifier", - "value": "Y", + "type": "String", + "value": "'./foo'", }, Object { "loc": Object { @@ -56773,26 +56688,8 @@ Object { }, }, "range": Array [ - 53, - 54, - ], - "type": "Punctuator", - "value": ">", - }, - Object { - "loc": Object { - "end": Object { - "column": 26, - "line": 2, - }, - "start": Object { - "column": 25, - "line": 2, - }, - }, - "range": Array [ - 54, - 55, + 79, + 80, ], "type": "Punctuator", "value": ";", @@ -56802,31 +56699,14 @@ Object { } `; -exports[`typescript fixtures/basics/import-type-with-type-parameters-in-type-reference.src 1`] = ` +exports[`typescript fixtures/basics/import-type-error.src 1`] = ` Object { "body": Array [ Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 6, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, - }, - "name": "X", - "range": Array [ - 5, - 6, - ], - "type": "Identifier", - }, + "importKind": "type", "loc": Object { "end": Object { - "column": 30, + "column": 36, "line": 1, }, "start": Object { @@ -56836,171 +56716,118 @@ Object { }, "range": Array [ 0, - 30, + 36, ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { + "source": Object { "loc": Object { "end": Object { - "column": 29, + "column": 35, "line": 1, }, "start": Object { - "column": 9, + "column": 30, "line": 1, }, }, "range": Array [ - 9, - 29, + 30, + 35, ], - "type": "TSTypeReference", - "typeName": Object { + "raw": "'bar'", + "type": "Literal", + "value": "bar", + }, + "specifiers": Array [ + Object { "loc": Object { "end": Object { - "column": 10, + "column": 15, "line": 1, }, "start": Object { - "column": 9, + "column": 7, "line": 1, }, }, - "name": "A", + "local": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 12, + 15, + ], + "type": "Identifier", + }, "range": Array [ - 9, - 10, + 7, + 15, ], - "type": "Identifier", + "type": "ImportDefaultSpecifier", }, - "typeParameters": Object { + Object { + "imported": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "name": "bar", + "range": Array [ + 19, + 22, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 29, + "column": 22, "line": 1, }, "start": Object { - "column": 10, + "column": 19, "line": 1, }, }, - "params": Array [ - Object { - "isTypeOf": false, - "loc": Object { - "end": Object { - "column": 28, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "parameter": Object { - "literal": Object { - "loc": Object { - "end": Object { - "column": 20, - "line": 1, - }, - "start": Object { - "column": 18, - "line": 1, - }, - }, - "range": Array [ - 18, - 20, - ], - "raw": "\\"\\"", - "type": "Literal", - "value": "", - }, - "loc": Object { - "end": Object { - "column": 20, - "line": 1, - }, - "start": Object { - "column": 18, - "line": 1, - }, - }, - "range": Array [ - 18, - 20, - ], - "type": "TSLiteralType", - }, - "qualifier": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 1, - }, - "start": Object { - "column": 22, - "line": 1, - }, - }, - "name": "B", - "range": Array [ - 22, - 23, - ], - "type": "Identifier", + "local": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, }, - "range": Array [ - 11, - 28, - ], - "type": "TSImportType", - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 28, - "line": 1, - }, - "start": Object { - "column": 23, - "line": 1, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 24, - "line": 1, - }, - }, - "range": Array [ - 24, - 27, - ], - "type": "TSAnyKeyword", - }, - ], - "range": Array [ - 23, - 28, - ], - "type": "TSTypeParameterInstantiation", + "start": Object { + "column": 19, + "line": 1, }, }, - ], + "name": "bar", + "range": Array [ + 19, + 22, + ], + "type": "Identifier", + }, "range": Array [ - 10, - 29, + 19, + 22, ], - "type": "TSTypeParameterInstantiation", + "type": "ImportSpecifier", }, - }, + ], + "type": "ImportDeclaration", }, ], "loc": Object { @@ -57015,14 +56842,14 @@ Object { }, "range": Array [ 0, - 31, + 37, ], - "sourceType": "script", + "sourceType": "module", "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 4, + "column": 6, "line": 1, }, "start": Object { @@ -57032,33 +56859,15 @@ Object { }, "range": Array [ 0, - 4, - ], - "type": "Identifier", - "value": "type", - }, - Object { - "loc": Object { - "end": Object { - "column": 6, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, - }, - "range": Array [ - 5, 6, ], - "type": "Identifier", - "value": "X", + "type": "Keyword", + "value": "import", }, Object { "loc": Object { "end": Object { - "column": 8, + "column": 11, "line": 1, }, "start": Object { @@ -57068,64 +56877,46 @@ Object { }, "range": Array [ 7, - 8, + 11, ], - "type": "Punctuator", - "value": "=", + "type": "Identifier", + "value": "type", }, Object { "loc": Object { "end": Object { - "column": 10, + "column": 15, "line": 1, }, "start": Object { - "column": 9, + "column": 12, "line": 1, }, }, "range": Array [ - 9, - 10, + 12, + 15, ], "type": "Identifier", - "value": "A", + "value": "foo", }, Object { "loc": Object { "end": Object { - "column": 11, + "column": 16, "line": 1, }, "start": Object { - "column": 10, + "column": 15, "line": 1, }, }, "range": Array [ - 10, - 11, + 15, + 16, ], "type": "Punctuator", - "value": "<", - }, - Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "range": Array [ - 11, - 17, - ], - "type": "Keyword", - "value": "import", + "value": ",", }, Object { "loc": Object { @@ -57143,166 +56934,984 @@ Object { 18, ], "type": "Punctuator", - "value": "(", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 20, + "column": 22, "line": 1, }, "start": Object { - "column": 18, + "column": 19, "line": 1, }, }, "range": Array [ - 18, - 20, + 19, + 22, ], - "type": "String", - "value": "\\"\\"", + "type": "Identifier", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 21, + "column": 24, "line": 1, }, "start": Object { - "column": 20, + "column": 23, "line": 1, }, }, "range": Array [ - 20, - 21, + 23, + 24, ], "type": "Punctuator", - "value": ")", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 22, + "column": 29, "line": 1, }, "start": Object { - "column": 21, + "column": 25, "line": 1, }, }, "range": Array [ - 21, - 22, + 25, + 29, ], - "type": "Punctuator", - "value": ".", + "type": "Identifier", + "value": "from", }, Object { "loc": Object { "end": Object { - "column": 23, + "column": 35, "line": 1, }, "start": Object { - "column": 22, + "column": 30, "line": 1, }, }, "range": Array [ - 22, - 23, + 30, + 35, ], - "type": "Identifier", - "value": "B", + "type": "String", + "value": "'bar'", }, Object { "loc": Object { "end": Object { - "column": 24, + "column": 36, "line": 1, }, "start": Object { - "column": 23, + "column": 35, "line": 1, }, }, "range": Array [ - 23, - 24, + 35, + 36, ], "type": "Punctuator", - "value": "<", + "value": ";", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/import-type-named.src 1`] = ` +Object { + "body": Array [ Object { + "importKind": "type", "loc": Object { "end": Object { - "column": 27, + "column": 36, "line": 1, }, "start": Object { - "column": 24, + "column": 0, "line": 1, }, }, "range": Array [ - 24, - 27, + 0, + 36, + ], + "source": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 30, + "line": 1, + }, + }, + "range": Array [ + 30, + 35, + ], + "raw": "'baz'", + "type": "Literal", + "value": "baz", + }, + "specifiers": Array [ + Object { + "imported": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 14, + 17, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "local": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 14, + 17, + ], + "type": "Identifier", + }, + "range": Array [ + 14, + 17, + ], + "type": "ImportSpecifier", + }, + Object { + "imported": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "name": "bar", + "range": Array [ + 19, + 22, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "local": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "name": "bar", + "range": Array [ + 19, + 22, + ], + "type": "Identifier", + }, + "range": Array [ + 19, + 22, + ], + "type": "ImportSpecifier", + }, + ], + "type": "ImportDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 37, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "import", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 11, ], "type": "Identifier", - "value": "any", + "value": "type", }, Object { "loc": Object { "end": Object { - "column": 28, + "column": 13, "line": 1, }, "start": Object { - "column": 27, + "column": 12, "line": 1, }, }, "range": Array [ - 27, - 28, + 12, + 13, ], "type": "Punctuator", - "value": ">", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 29, + "column": 17, "line": 1, }, "start": Object { - "column": 28, + "column": 14, "line": 1, }, }, "range": Array [ - 28, - 29, + 14, + 17, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, ], "type": "Punctuator", - "value": ">", + "value": ",", }, Object { "loc": Object { "end": Object { - "column": 30, + "column": 22, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 22, + ], + "type": "Identifier", + "value": "bar", + }, + 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": 29, "line": 1, }, + "start": Object { + "column": 25, + "line": 1, + }, }, "range": Array [ + 25, 29, + ], + "type": "Identifier", + "value": "from", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 30, + "line": 1, + }, + }, + "range": Array [ 30, + 35, + ], + "type": "String", + "value": "'baz'", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "range": Array [ + 35, + 36, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/import-type-named-as.src 1`] = ` +Object { + "body": Array [ + Object { + "importKind": "type", + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 38, + ], + "source": Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 32, + "line": 1, + }, + }, + "range": Array [ + 32, + 37, + ], + "raw": "'baz'", + "type": "Literal", + "value": "baz", + }, + "specifiers": Array [ + Object { + "imported": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 14, + 17, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "local": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "name": "bar", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + "range": Array [ + 14, + 24, + ], + "type": "ImportSpecifier", + }, + ], + "type": "ImportDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 39, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "import", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 11, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 17, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 20, + ], + "type": "Identifier", + "value": "as", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 31, + ], + "type": "Identifier", + "value": "from", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 32, + "line": 1, + }, + }, + "range": Array [ + 32, + 37, + ], + "type": "String", + "value": "'baz'", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 37, + "line": 1, + }, + }, + "range": Array [ + 37, + 38, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/import-type-star-as-ns.src 1`] = ` +Object { + "body": Array [ + Object { + "importKind": "type", + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 34, + ], + "source": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 33, + ], + "raw": "'./bar'", + "type": "Literal", + "value": "./bar", + }, + "specifiers": Array [ + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "local": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 17, + 20, + ], + "type": "Identifier", + }, + "range": Array [ + 12, + 20, + ], + "type": "ImportNamespaceSpecifier", + }, + ], + "type": "ImportDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 35, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "import", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 11, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": "*", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 16, + ], + "type": "Identifier", + "value": "as", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 20, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 25, + ], + "type": "Identifier", + "value": "from", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 33, + ], + "type": "String", + "value": "'./bar'", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 34, ], "type": "Punctuator", "value": ";", @@ -67252,6 +67861,7 @@ Object { "type": "BlockStatement", }, Object { + "importKind": "value", "loc": Object { "end": Object { "column": 21, @@ -97485,6 +98095,1033 @@ Object { } `; +exports[`typescript fixtures/basics/type-alias-declaration-export.src 1`] = ` +Object { + "body": Array [ + Object { + "declaration": Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "name": "TestAlias", + "range": Array [ + 12, + 21, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 40, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 40, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 39, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 39, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 30, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 39, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 39, + ], + "type": "TSNumberKeyword", + }, + ], + }, + }, + "exportKind": "type", + "loc": Object { + "end": Object { + "column": 40, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 40, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 40, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 40, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 11, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 21, + ], + "type": "Identifier", + "value": "TestAlias", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 30, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 39, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 39, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 40, + "line": 1, + }, + "start": Object { + "column": 39, + "line": 1, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/type-alias-declaration-export-function-type.src 1`] = ` +Object { + "body": Array [ + Object { + "declaration": Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "name": "TestCallback", + "range": Array [ + 12, + 24, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 47, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 28, + 37, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 37, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 37, + ], + "type": "TSNumberKeyword", + }, + }, + }, + ], + "range": Array [ + 27, + 46, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 39, + "line": 1, + }, + }, + "range": Array [ + 39, + 46, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 42, + "line": 1, + }, + }, + "range": Array [ + 42, + 46, + ], + "type": "TSVoidKeyword", + }, + }, + "type": "TSFunctionType", + }, + }, + "exportKind": "type", + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 47, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 47, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 11, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 24, + ], + "type": "Identifier", + "value": "TestCallback", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 30, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 37, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 37, + "line": 1, + }, + }, + "range": Array [ + 37, + 38, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 1, + }, + "start": Object { + "column": 39, + "line": 1, + }, + }, + "range": Array [ + 39, + 41, + ], + "type": "Punctuator", + "value": "=>", + }, + Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 42, + "line": 1, + }, + }, + "range": Array [ + 42, + 46, + ], + "type": "Keyword", + "value": "void", + }, + Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 46, + "line": 1, + }, + }, + "range": Array [ + 46, + 47, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/type-alias-declaration-export-object-type.src 1`] = ` +Object { + "body": Array [ + Object { + "declaration": Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "name": "TestClassProps", + "range": Array [ + 12, + 26, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 2, + "line": 3, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 51, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "members": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "name": "count", + "range": Array [ + 35, + 40, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 35, + 48, + ], + "type": "TSPropertySignature", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 40, + 48, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 42, + 48, + ], + "type": "TSNumberKeyword", + }, + }, + }, + ], + "range": Array [ + 29, + 50, + ], + "type": "TSTypeLiteral", + }, + }, + "exportKind": "type", + "loc": Object { + "end": Object { + "column": 2, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 51, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 2, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 51, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 11, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 26, + ], + "type": "Identifier", + "value": "TestClassProps", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 30, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 35, + 40, + ], + "type": "Identifier", + "value": "count", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 40, + 41, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 42, + 48, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 49, + 50, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 3, + }, + "start": Object { + "column": 1, + "line": 3, + }, + }, + "range": Array [ + 50, + 51, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/basics/type-alias-declaration-with-constrained-type-parameter.src 1`] = ` Object { "body": Array [ @@ -106358,6 +107995,1189 @@ Object { } `; +exports[`typescript fixtures/basics/type-import-type.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "A", + "range": Array [ + 5, + 6, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 28, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "isTypeOf": true, + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "parameter": Object { + "literal": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 26, + ], + "raw": "'A'", + "type": "Literal", + "value": "A", + }, + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 26, + ], + "type": "TSLiteralType", + }, + "qualifier": null, + "range": Array [ + 9, + 27, + ], + "type": "TSImportType", + "typeParameters": null, + }, + }, + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 2, + }, + "start": Object { + "column": 5, + "line": 2, + }, + }, + "name": "B", + "range": Array [ + 34, + 35, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 29, + 55, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "isTypeOf": false, + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "parameter": Object { + "literal": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 45, + 48, + ], + "raw": "\\"B\\"", + "type": "Literal", + "value": "B", + }, + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 45, + 48, + ], + "type": "TSLiteralType", + }, + "qualifier": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 21, + "line": 2, + }, + }, + "name": "X", + "range": Array [ + 50, + 51, + ], + "type": "Identifier", + }, + "range": Array [ + 38, + 54, + ], + "type": "TSImportType", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 22, + "line": 2, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "range": Array [ + 52, + 53, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "Y", + "range": Array [ + 52, + 53, + ], + "type": "Identifier", + }, + }, + ], + "range": Array [ + 51, + 54, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 56, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 15, + ], + "type": "Keyword", + "value": "typeof", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 22, + ], + "type": "Keyword", + "value": "import", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 26, + ], + "type": "String", + "value": "'A'", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 29, + 33, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 2, + }, + "start": Object { + "column": 5, + "line": 2, + }, + }, + "range": Array [ + 34, + 35, + ], + "type": "Identifier", + "value": "B", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "range": Array [ + 36, + 37, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 38, + 44, + ], + "type": "Keyword", + "value": "import", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 44, + 45, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 45, + 48, + ], + "type": "String", + "value": "\\"B\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 19, + "line": 2, + }, + }, + "range": Array [ + 48, + 49, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 20, + "line": 2, + }, + }, + "range": Array [ + 49, + 50, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 21, + "line": 2, + }, + }, + "range": Array [ + 50, + 51, + ], + "type": "Identifier", + "value": "X", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 22, + "line": 2, + }, + }, + "range": Array [ + 51, + 52, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "range": Array [ + 52, + 53, + ], + "type": "Identifier", + "value": "Y", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "range": Array [ + 53, + 54, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 25, + "line": 2, + }, + }, + "range": Array [ + 54, + 55, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/type-import-type-with-type-parameters-in-type-reference.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "X", + "range": Array [ + 5, + 6, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 30, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 29, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "A", + "range": Array [ + 9, + 10, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "params": Array [ + Object { + "isTypeOf": false, + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "parameter": Object { + "literal": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 20, + ], + "raw": "\\"\\"", + "type": "Literal", + "value": "", + }, + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 20, + ], + "type": "TSLiteralType", + }, + "qualifier": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "name": "B", + "range": Array [ + 22, + 23, + ], + "type": "Identifier", + }, + "range": Array [ + 11, + 28, + ], + "type": "TSImportType", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 27, + ], + "type": "TSAnyKeyword", + }, + ], + "range": Array [ + 23, + 28, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + ], + "range": Array [ + 10, + 29, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 31, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Identifier", + "value": "X", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Identifier", + "value": "A", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "Keyword", + "value": "import", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 20, + ], + "type": "String", + "value": "\\"\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Identifier", + "value": "B", + }, + 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": 27, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 27, + ], + "type": "Identifier", + "value": "any", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 30, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/basics/type-parameters-comments.src 1`] = ` Object { "body": Array [ @@ -134687,6 +137507,7 @@ Object { ], "type": "TSEnumDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 72, @@ -145776,6 +148597,7 @@ Object { "body": Object { "body": Array [ Object { + "importKind": "value", "loc": Object { "end": Object { "column": 22, @@ -146290,6 +149112,7 @@ Object { }, "type": "TSDeclareFunction", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 59, @@ -148070,6 +150893,7 @@ Object { ], "type": "VariableDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 32, @@ -148363,6 +151187,7 @@ Object { "superClass": null, "type": "ClassDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 5, @@ -148510,6 +151335,7 @@ Object { ], "type": "TSInterfaceDeclaration", }, + "exportKind": "type", "loc": Object { "end": Object { "column": 9, @@ -148579,6 +151405,7 @@ Object { ], "type": "TSModuleDeclaration", }, + "exportKind": "value", "loc": Object { "end": Object { "column": 5,