0

Problem

When using typescript I can access hover-help from the language server for my variables. Given this snippet of code:

interface X {
    x1: string;
    x2: number;
}

type Y = {
    y1: boolean;
    y2: number;
};

export type Z = X | Y;

getting the types for Z, Y, and X produce different kinds of results. See the screenshots below:

✔️ Help for Y

As you can see, the help for Y is great. It shows me all the members of Y.

Help for Y

❌ Help for X

The help for X however, is pretty awful because "what is X?" results in "X is X." Not great.

Help for X

❌ Help for Z

And for Z, it isn't much better. It just regurgitates the exact definition from the line on which it was defined.

Help for Z

Desired Outcome

When I activate hover-help for a type/interface, I am usually interested in seeing all the members of that type. However, with nested interfaces I just get the top-level and it's often minimally helpful if not totally useless.

Is there a way to get more information here? Perhaps I can "expand" the types in the hover-help? Or maybe there's a setting to recursively expand?

Workaround

Currently I just type const foo = null as unknown as Z; to get myself a quick and dirty "instance of Z" and then I type foo. and use the auto-suggestion popup after the . to see all the members. As you can imagine, I really hate doing this.

Other Information

Note: I'm using Vim with CoC, but this should also apply to other editors.

Playground Link

nullromo
  • 2,165
  • 2
  • 18
  • 39
  • The solutions in the duplicate _technically_ work, but would require me to modify every single complex type definition in my source code to work properly. However, I suppose the answer of basically "you can't do this" and/or "there is no implementation for this right now" is good enough, albeit not what I wanted to hear. – nullromo Dec 13 '22 at 00:06

0 Answers0