From a263218ea4d979197d68177d65353101f0e5f666 Mon Sep 17 00:00:00 2001 From: Ika Date: Sun, 5 Aug 2018 00:30:02 +0800 Subject: [PATCH 1/6] test: add tests --- lib/ast-node-types.js | 2 + ...import-type-with-generic-in-generic.src.ts | 1 + tests/lib/__snapshots__/typescript.js.snap | 582 ++++++++++++++++++ 3 files changed, 585 insertions(+) create mode 100644 tests/fixtures/typescript/basics/import-type-with-generic-in-generic.src.ts diff --git a/lib/ast-node-types.js b/lib/ast-node-types.js index 3826a53..f7da002 100644 --- a/lib/ast-node-types.js +++ b/lib/ast-node-types.js @@ -113,6 +113,8 @@ module.exports = { TSEnumMember: "TSEnumMember", TSExportAssignment: "TSExportAssignment", TSExportKeyword: "TSExportKeyword", + TSLastTypeNode: "TSLastTypeNode", + TSLiteralType: "TSLiteralType", TSIndexSignature: "TSIndexSignature", TSInterfaceBody: "TSInterfaceBody", TSInterfaceDeclaration: "TSInterfaceDeclaration", diff --git a/tests/fixtures/typescript/basics/import-type-with-generic-in-generic.src.ts b/tests/fixtures/typescript/basics/import-type-with-generic-in-generic.src.ts new file mode 100644 index 0000000..2c8acc1 --- /dev/null +++ b/tests/fixtures/typescript/basics/import-type-with-generic-in-generic.src.ts @@ -0,0 +1 @@ +type X = A>; diff --git a/tests/lib/__snapshots__/typescript.js.snap b/tests/lib/__snapshots__/typescript.js.snap index 9424f52..347b435 100644 --- a/tests/lib/__snapshots__/typescript.js.snap +++ b/tests/lib/__snapshots__/typescript.js.snap @@ -28774,6 +28774,588 @@ Object { } `; +exports[`typescript fixtures/basics/import-type-with-generic-in-generic.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": 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", + }, + "init": 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 { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 28, + ], + "type": "TSTypeReference", + "typeName": Object { + "argument": 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", + }, + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "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": "TSLastTypeNode", + "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", + }, + }, + "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": 30, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 30, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "type", + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 30, + ], + "type": "VariableDeclaration", + }, + ], + "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/interface-extends.src 1`] = ` Object { "body": Array [ From 44ed8616fc7cd11674af204521db1d308ab85b30 Mon Sep 17 00:00:00 2001 From: Ika Date: Sun, 5 Aug 2018 00:35:29 +0800 Subject: [PATCH 2/6] fix: ImportType with generic in TypeReference's generic --- lib/convert.js | 2 +- tests/lib/__snapshots__/typescript.js.snap | 36 ---------------------- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/lib/convert.js b/lib/convert.js index 7b561fc..1a50231 100644 --- a/lib/convert.js +++ b/lib/convert.js @@ -162,7 +162,7 @@ module.exports = function convert(config) { ], loc: nodeUtils.getLoc(typeArgument, ast), typeName: convertChild(typeArgument.typeName || typeArgument), - typeParameters: (typeArgument.typeArguments) + typeParameters: (typeArgument.typeArguments && typeArgument.kind !== SyntaxKind.ImportType) ? convertTypeArgumentsToTypeParameters(typeArgument.typeArguments) : undefined }; diff --git a/tests/lib/__snapshots__/typescript.js.snap b/tests/lib/__snapshots__/typescript.js.snap index 347b435..74d8de4 100644 --- a/tests/lib/__snapshots__/typescript.js.snap +++ b/tests/lib/__snapshots__/typescript.js.snap @@ -28967,42 +28967,6 @@ Object { "type": "TSTypeParameterInstantiation", }, }, - "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 [ From 8be0181644e6c4e2c98ad665864fd20aa709574f Mon Sep 17 00:00:00 2001 From: Ika Date: Sun, 5 Aug 2018 00:50:08 +0800 Subject: [PATCH 3/6] chore: workaround for jest issue ref: https://github.com/facebook/jest/issues/6766#issuecomment-408381957 --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 31863b2..6aa6243 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "typescript": "*" }, "jest": { + "testEnvironment": "node", "testRegex": "tests/lib/.+\\.js$", "testPathIgnorePatterns": [], "collectCoverage": true, From 081340212dcb6ce41b6e457b7804a48cfbf0d8d9 Mon Sep 17 00:00:00 2001 From: Ika Date: Sun, 5 Aug 2018 01:24:54 +0800 Subject: [PATCH 4/6] chore: workaround --- tests/ast-alignment/jest.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ast-alignment/jest.config.js b/tests/ast-alignment/jest.config.js index 0ac0625..2a310d0 100644 --- a/tests/ast-alignment/jest.config.js +++ b/tests/ast-alignment/jest.config.js @@ -1,5 +1,6 @@ "use strict"; module.exports = { + testEnvironment: "node", testRegex: "spec\\.js$" }; From 40e6854029c0ab36f688733d5c4a7fea26c94339 Mon Sep 17 00:00:00 2001 From: Ika Date: Sun, 5 Aug 2018 18:02:31 +0800 Subject: [PATCH 5/6] fix: remove unnecessary type reference --- lib/ast-node-types.js | 2 +- lib/convert.js | 14 +- tests/ast-alignment/fixtures-to-test.js | 6 +- ...-type-parameters-in-type-reference.src.ts} | 0 tests/lib/__snapshots__/typescript.js.snap | 147 ++++++++---------- 5 files changed, 84 insertions(+), 85 deletions(-) rename tests/fixtures/typescript/basics/{import-type-with-generic-in-generic.src.ts => import-type-with-type-parameters-in-type-reference.src.ts} (100%) diff --git a/lib/ast-node-types.js b/lib/ast-node-types.js index f7da002..155abac 100644 --- a/lib/ast-node-types.js +++ b/lib/ast-node-types.js @@ -113,7 +113,7 @@ module.exports = { TSEnumMember: "TSEnumMember", TSExportAssignment: "TSExportAssignment", TSExportKeyword: "TSExportKeyword", - TSLastTypeNode: "TSLastTypeNode", + TSImportType: "TSImportType", TSLiteralType: "TSLiteralType", TSIndexSignature: "TSIndexSignature", TSInterfaceBody: "TSInterfaceBody", diff --git a/lib/convert.js b/lib/convert.js index 1a50231..12688aa 100644 --- a/lib/convert.js +++ b/lib/convert.js @@ -154,6 +154,9 @@ module.exports = function convert(config) { loc: nodeUtils.getLoc(typeArgument, ast) }; } + if (typeArgument.kind === SyntaxKind.ImportType) { + return convert({ node: typeArgument, parent: null, ast, additionalOptions }); + } return { type: AST_NODE_TYPES.TSTypeReference, range: [ @@ -162,7 +165,7 @@ module.exports = function convert(config) { ], loc: nodeUtils.getLoc(typeArgument, ast), typeName: convertChild(typeArgument.typeName || typeArgument), - typeParameters: (typeArgument.typeArguments && typeArgument.kind !== SyntaxKind.ImportType) + typeParameters: (typeArgument.typeArguments) ? convertTypeArgumentsToTypeParameters(typeArgument.typeArguments) : undefined }; @@ -2141,6 +2144,15 @@ module.exports = function convert(config) { result.typeAnnotation.range = result.typeAnnotation.typeAnnotation.range; break; + case SyntaxKind.ImportType: + Object.assign(result, { + type: AST_NODE_TYPES.TSImportType, + parameter: convertChild(node.argument), + qualifier: convertChild(node.qualifier), + typeParameters: convertTypeArgumentsToTypeParameters(node.typeArguments) + }); + break; + case SyntaxKind.EnumDeclaration: { Object.assign(result, { type: AST_NODE_TYPES.TSEnumDeclaration, diff --git a/tests/ast-alignment/fixtures-to-test.js b/tests/ast-alignment/fixtures-to-test.js index f9af598..a845497 100644 --- a/tests/ast-alignment/fixtures-to-test.js +++ b/tests/ast-alignment/fixtures-to-test.js @@ -422,7 +422,11 @@ let fixturePatternConfigsToTest = [ "class-with-private-parameter-properties", "class-with-protected-parameter-properties", "class-with-public-parameter-properties", - "class-with-readonly-parameter-properties" + "class-with-readonly-parameter-properties", + /** + * Not yet supported in Babylon https://github.com/babel/babel/issues/7749 + */ + "import-type-with-type-parameters-in-type-reference" ], parseWithSourceTypeModule: [ "export-named-enum", diff --git a/tests/fixtures/typescript/basics/import-type-with-generic-in-generic.src.ts b/tests/fixtures/typescript/basics/import-type-with-type-parameters-in-type-reference.src.ts similarity index 100% rename from tests/fixtures/typescript/basics/import-type-with-generic-in-generic.src.ts rename to tests/fixtures/typescript/basics/import-type-with-type-parameters-in-type-reference.src.ts diff --git a/tests/lib/__snapshots__/typescript.js.snap b/tests/lib/__snapshots__/typescript.js.snap index 74d8de4..35ab330 100644 --- a/tests/lib/__snapshots__/typescript.js.snap +++ b/tests/lib/__snapshots__/typescript.js.snap @@ -28774,7 +28774,7 @@ Object { } `; -exports[`typescript fixtures/basics/import-type-with-generic-in-generic.src 1`] = ` +exports[`typescript fixtures/basics/import-type-with-type-parameters-in-type-reference.src 1`] = ` Object { "body": Array [ Object { @@ -28855,32 +28855,8 @@ Object { "line": 1, }, }, - "range": Array [ - 11, - 28, - ], - "type": "TSTypeReference", - "typeName": Object { - "argument": 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": "", - }, + "parameter": Object { + "literal": Object { "loc": Object { "end": Object { "column": 20, @@ -28895,77 +28871,84 @@ Object { 18, 20, ], - "type": "TSLiteralType", + "raw": "\\"\\"", + "type": "Literal", + "value": "", }, "loc": Object { "end": Object { - "column": 28, + "column": 20, "line": 1, }, "start": Object { - "column": 11, + "column": 18, "line": 1, }, }, - "qualifier": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 1, - }, - "start": Object { - "column": 22, - "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", }, + "name": "B", "range": Array [ - 11, - 28, + 22, + 23, ], - "type": "TSLastTypeNode", - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 28, - "line": 1, - }, - "start": Object { - "column": 23, - "line": 1, - }, + "type": "Identifier", + }, + "range": Array [ + 11, + 28, + ], + "type": "TSImportType", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 24, - "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 [ + 24, + 27, + ], + "type": "TSAnyKeyword", + }, + ], + "range": Array [ + 23, + 28, + ], + "type": "TSTypeParameterInstantiation", }, }, ], From 504a576277b744ba31f293db5453bca9fe0e2cb4 Mon Sep 17 00:00:00 2001 From: Ika Date: Sun, 5 Aug 2018 20:18:47 +0800 Subject: [PATCH 6/6] fix: add missing isTypeOf --- lib/convert.js | 3 +- tests/ast-alignment/fixtures-to-test.js | 1 + .../typescript/basics/import-type.src.ts | 2 + tests/lib/__snapshots__/typescript.js.snap | 714 ++++++++++++++++++ 4 files changed, 719 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/typescript/basics/import-type.src.ts diff --git a/lib/convert.js b/lib/convert.js index 12688aa..ac295eb 100644 --- a/lib/convert.js +++ b/lib/convert.js @@ -2147,9 +2147,10 @@ module.exports = function convert(config) { case SyntaxKind.ImportType: Object.assign(result, { type: AST_NODE_TYPES.TSImportType, + isTypeOf: !!node.isTypeOf, parameter: convertChild(node.argument), qualifier: convertChild(node.qualifier), - typeParameters: convertTypeArgumentsToTypeParameters(node.typeArguments) + typeParameters: node.typeArguments ? convertTypeArgumentsToTypeParameters(node.typeArguments) : null }); break; diff --git a/tests/ast-alignment/fixtures-to-test.js b/tests/ast-alignment/fixtures-to-test.js index a845497..338dd15 100644 --- a/tests/ast-alignment/fixtures-to-test.js +++ b/tests/ast-alignment/fixtures-to-test.js @@ -426,6 +426,7 @@ let fixturePatternConfigsToTest = [ /** * Not yet supported in Babylon https://github.com/babel/babel/issues/7749 */ + "import-type", "import-type-with-type-parameters-in-type-reference" ], parseWithSourceTypeModule: [ diff --git a/tests/fixtures/typescript/basics/import-type.src.ts b/tests/fixtures/typescript/basics/import-type.src.ts new file mode 100644 index 0000000..00e3ba6 --- /dev/null +++ b/tests/fixtures/typescript/basics/import-type.src.ts @@ -0,0 +1,2 @@ +type A = typeof import('A'); +type B = import("B").X; diff --git a/tests/lib/__snapshots__/typescript.js.snap b/tests/lib/__snapshots__/typescript.js.snap index 35ab330..8beb320 100644 --- a/tests/lib/__snapshots__/typescript.js.snap +++ b/tests/lib/__snapshots__/typescript.js.snap @@ -28774,6 +28774,719 @@ Object { } `; +exports[`typescript fixtures/basics/import-type.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": 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", + }, + "init": 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, + }, + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 28, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "type", + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 28, + ], + "type": "VariableDeclaration", + }, + Object { + "declarations": Array [ + 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", + }, + "init": 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": 26, + "line": 2, + }, + "start": Object { + "column": 5, + "line": 2, + }, + }, + "range": Array [ + 34, + 55, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "type", + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 29, + 55, + ], + "type": "VariableDeclaration", + }, + ], + "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/import-type-with-type-parameters-in-type-reference.src 1`] = ` Object { "body": Array [ @@ -28845,6 +29558,7 @@ Object { }, "params": Array [ Object { + "isTypeOf": false, "loc": Object { "end": Object { "column": 28,