Skip to content

Commit

Permalink
add jsdoc import type tag go to definition tests
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk committed Jan 29, 2024
1 parent fc4ac15 commit df23ce3
Show file tree
Hide file tree
Showing 16 changed files with 555 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/services/jsDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ const jsDocTagNames = [
"host",
"ignore",
"implements",
"importType",
"inheritdoc",
"inner",
"instance",
Expand Down
2 changes: 2 additions & 0 deletions src/services/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ import {
isInternalModuleImportEqualsDeclaration,
isJSDoc,
isJSDocCommentContainingNode,
isJSDocImportTypeTag,
isJSDocLink,
isJSDocLinkCode,
isJSDocLinkLike,
Expand Down Expand Up @@ -2574,6 +2575,7 @@ export function isModuleSpecifierLike(node: Node): node is StringLiteralLike {
return isStringLiteralLike(node) && (
isExternalModuleReference(node.parent) ||
isImportDeclaration(node.parent) ||
isJSDocImportTypeTag(node.parent) ||
isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ false) && node.parent.arguments[0] === node ||
isImportCall(node.parent) && node.parent.arguments[0] === node
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// === goToDefinition ===
// === /b.ts ===
// [||]export interface A { }

// === /a.js ===
// /**
// * @importType { A } from [|"./b/*GOTO DEF*/"|]
// */

// === Details ===
[
{
"kind": "script",
"name": "./b",
"unverified": false
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// === goToDefinition ===
// === /a.js ===
// /**
// * @importType { A } from/*GOTO DEF*/ "./b"
// */
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// === goToDefinition ===
// === /a.js ===
// /**
// * @importType { A } from /*GOTO DEF*/ "./b";
// */
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// === goToDefinition ===
// === /b.ts ===
// <|export interface [|A|] { }|>

// === /a.js ===
// /**
// * @importType { [|A|]/*GOTO DEF*/ } from "./b";
// */

// === Details ===
[
{
"kind": "interface",
"name": "A",
"containerName": "\"/b\"",
"isLocal": false,
"isAmbient": false,
"unverified": false
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// === goToDefinition ===
// === /b.ts ===
// <|export interface [|A|] { }|>

// === /a.js ===
// /**
// * @importType { A } from "./b";
// */
//
// /**
// * @param { [|A|]/*GOTO DEF*/ } a
// */
// function f(a) {}

// === Details ===
[
{
"kind": "interface",
"name": "A",
"containerName": "\"/b\"",
"isLocal": false,
"isAmbient": false,
"unverified": false
}
]
Loading

0 comments on commit df23ce3

Please sign in to comment.