Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enums and interfaces do not have definitions in quick info/tooltips #25894

Open
4 tasks
LAITONEN opened this issue Jul 24, 2018 · 5 comments
Open
4 tasks

Enums and interfaces do not have definitions in quick info/tooltips #25894

LAITONEN opened this issue Jul 24, 2018 · 5 comments
Labels
Domain: Quick Info e.g. hover text, tool-tips, and tooltips. Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Suggestion An idea for TypeScript
Milestone

Comments

@LAITONEN
Copy link

LAITONEN commented Jul 24, 2018

The issue might be related to this one, but mine is not about version 3.0, and is not solely about imports.

Search Terms

enum, description, definition, pop-up, tooltip, vs code, interface, suggestion

Suggestion

Hovering over enums and interfaces, should show their definition, i.e. I have this enum (or an interface):

enum enumName {
    ONE = 1;
    TWO = 2;
    THREE = 3;
}

If I hover over this enum, wherever I use it (whether it is imported to another file or used locally where it is declared), I would like to see what this enum is all about (essentially what are the properties).

This is what I see right now when I hover over enums or interfaces:
image
image

As a workaround, I currently need to add this type of JSDoc comments right above the enum declaration.

/** Props:
*    @param ONE 1;
*    @param TWO 2;
*    @param THREE 3;
*/

Which yields to:
image

Use Cases

This feature would save time & effort.
The shortcoming of the current approach is that either need to add ${2+numberOfEnumProperties} lines of comments or go to the file, where enum is declared, locate the enum there and then familiarize myself with its properties.

Examples

image

Checklist

I am not that experienced to be able to answer the questions below.

  • This wouldn't be a breaking change in existing TypeScript / JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. new expression-level syntax)
@LAITONEN
Copy link
Author

LAITONEN commented Jul 24, 2018

Also, if I have interface, which extends another interface:

interface One {
    one: number;
}

interface Two extends One {
    two: string;
}

And I use interface Two somewhere and hover over it, I will get the same dull description as I got on the second screenshot in the initial post with interfaceName, so not only there is no description of a specified properties, but it does not even show which interfaces it extends.

@mhegazy mhegazy added the Suggestion An idea for TypeScript label Jul 24, 2018
@mhegazy mhegazy added this to the TypeScript 3.1 milestone Jul 24, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Jul 24, 2018

I agree. hovering over a type name to get a pop-up with the same text is rather useless. we can do better.

@DanielRosenwasser DanielRosenwasser added Help Wanted You can do this Domain: Quick Info e.g. hover text, tool-tips, and tooltips. labels Oct 30, 2018
@DanielRosenwasser DanielRosenwasser changed the title Enums and interfaces do not have definitions in pop-ups Enums and interfaces do not have definitions in quick info/tooltips Oct 30, 2018
@RyanCavanaugh RyanCavanaugh added the Experience Enhancement Noncontroversial enhancements label Mar 13, 2019
@RyanCavanaugh RyanCavanaugh removed this from the TypeScript 3.4.0 milestone Mar 13, 2019
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Aug 16, 2019
@ro-savage
Copy link

Just adding on to this. I find it really annoying that the type information for interfaces and enums are basically useless.

It also affects all the IDEs when they display the definitions. See this one for JetBrains IDE's: https://youtrack.jetbrains.com/oauth?state=%2Fissue%2FWEB-44531

@ro-savage
Copy link

Could someone point out where in the code base these definitions are created, and especially where the Types one are vs the Interface.

Then maybe someone from the community can take a look at actioning this.

@orta
Copy link
Contributor

orta commented Apr 17, 2020

My tactic for figuring out stuff like this is to enable TSServer logging, perform the action you're interested in, then see what requests were made:

    {"seq":270,"type":"request","command":"quickinfo","arguments":{"file":"/Users/ortatherox/dev/typescript/new-website/packages/sandbox/src/typeAcquisition.ts","line":15,"offset":15}}

So this request is a quickinfo - a search I the codebase finds getQuickInfoAtPosition - which is where the code starts - my bet, the code you're looking for is in SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Quick Info e.g. hover text, tool-tips, and tooltips. Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

7 participants