Skip to content

Typescript "Go to Definition" goes to function type, not its implementation #18321

Closed
@ta-stott-oe

Description

@ta-stott-oe
  • VSCode Version: 1.8.1
  • OS Version: Windows 10

Steps to Reproduce:

  1. In a.ts, export a function type:
export interface MyFunctionType {
    (): string;
}
  1. In b.ts, import the type and export a variable which implements it
import {MyFunctionType} from "./a";
export function MyFunction: MyFunctionType = () => {
    return "test";
}
  1. In c.ts, import the function variable, and invoke it
import {MyFunction} from "./b";
MyFunction();
  1. Place the caret somewhere inside the function call and Go to Definition.

Outcome
VSC takes you to a.ts (where the type of the variable is defined), not b.ts (where the variable is defined).

Real life example
You have a Knockout view model class with properties of type KnockoutObservable<T> (which may be invoked as a function). When you try to navigate to the definition of such a property, VSC takes you to the definition of KnockoutObservable in knockout.d.ts, not to the view model class.

Metadata

Metadata

Assignees

Labels

*duplicateIssue identified as a duplicate of another issue(s)feature-requestRequest for new features or functionalityjavascriptJavaScript support issuestypescriptTypescript support issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions