question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:6
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
tnrichcommented, Jan 25, 2020

@mjbvz

Hand authoring d.ts files for js files that you already have the code for is sort of an odd case.

I would argue that this is actually a very frequent case, think of all the pure js libraries that have d.ts files. IMO there should be a way to jump to either the definition file or completely disregard the definition file and jump to the source code.

1reaction
RyanCavanaughcommented, Jan 27, 2020

From an architectural perspective, this is a bit of a jump for us. If there’s a .d.ts file, we don’t even look for .js and wouldn’t realize that there was another option to even go to. If we did decide this was worth investing in based on feedback, there’d need to be a separate verb so that we didn’t spend a bunch of timing trying to load JS files the user wasn’t interested in.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cmd+click skip typescript definition and go to source? #68782
I'm unsure why we can CMD + click on code in JS files and it points us to the entity's assignment/definition within a...
Read more >
Go to implementation instead of TypeScript declaration
Try Go to source definition. This command will try to jump to the original JavaScript implementation of a function/symbol, even for code ...
Read more >
Better mapping between *.js and *.d.ts files : WEB-47153
I navigate to the index.d.ts file instead of index.js source file. Looks like Webstorm prioritizes type definition file over source file when in...
Read more >
Configure your Data Set - Tableau Help
Configure your Data Set · Right-click or Cmd-click (MacOS) on the Input step to rename or remove it. · Search for fields. ·...
Read more >
July 2018 (version 1.26) - Visual Studio Code
If you'd like to read these release notes online, go to Updates on ... If you are not using editor tabs, breadcrumbs show...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found