microsoft / microsoft/TypeScript

cmd+click function name goes to type definition file instead of source

Open
#36,418 5 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

duplicate of microsoft/vscode#68782 but that was closed without fix.

  • VSCode Version: 1.41.1
  • OS Version: macOS 10.14.6

Steps to Reproduce:

  1. Create a project folder with 2 files:

lib.js

export const testMethod = (name, params) => {
  params && params.age
    ? `hello ${name} with age: ${params.age}`
    : `hello ${name}`;
};

test.js

import { testMethod } from "./lib";
testMethod("foo", { age: 3 });

cmd+click works and jumps to definition.

no-type

now add a type definition file

lib.d.ts

declare namespace MyModule {
  interface IParams {
    age: number;
  }

  function testMethod(name: string, params: IParams): string;
}
export = MyModule;

cmd+click jumps to type definition instead of source definition.

with-type-file

I do not think this should be the default behavior. I would expect cmd+click to bring me to the function definition.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the navigation behavior with the mentioned lib.js and test.js files, then add lib.d.ts and compare the cmd-click target. Start by tracing the definition lookup behavior in the TypeScript language service; done means navigation reaches the source function in lib.js rather than only the declaration in lib.d.ts.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.