Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add way to differentiate references for definitions at requesting location 聽#42889

Copy link
Copy link

Description

@mjbvz
Issue body actions

Bug Report

馃攷 Search Terms

  • references
  • find all references

Problem

We use the references request to power VS Code's references code lens feature. References returned by TS have an optional isDefinition property that tells if the reference is to a definition or not. We use this to avoid showing multiple references for a case such as:

function foo(a: number): number;
function foo(a: string): string;
function foo(a: string | number): string | number;

The references code lens basically just filtered out any references that are marked isDefinition

However this also prevents us from showing the correct reference count in cases such as:

interface IFoo {
    foo(): void;
}

class Foo implements IFoo {
    foo(): void { }
}

In this case, the two references to foo should have 1 reference, but we show 0 references because both references are definitions.

microsoft/vscode#117021 shows another case with object literal shortcut

Proposal

We'd like a new property on the references response that tells us if the reference belongs to definition from the requesting location (not yet sure what the name of this should be).

For a case with overloads such as:

function foo(a: number): number;
function foo(a: string): string;
function foo(a: string | number): string | number;

If we request references on any of the calls to foo, this new property would be marked true. However it would not be true in cases such as:

export const foo = 123;

console.log({ foo });

or:

interface IFoo {
    foo(): void;
}

class Foo implements IFoo {
    foo(): void { }
}
Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Domain: LS: Symbol NavigationRelates to go-to-definition, find-all-references, highlighting/occurrences.Relates to go-to-definition, find-all-references, highlighting/occurrences.Fix AvailableA PR has been opened for this issueA PR has been opened for this issueIn DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScriptVS Code PriorityCritical issues that VS Code needs fixed in the current TypeScript milestoneCritical issues that VS Code needs fixed in the current TypeScript milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

Morty Proxy This is a proxified and sanitized view of the page, visit original site.