Search code examples
typescriptvisual-studio-codevscode-extensions

Vscode Typescript: Display alias of type rather than its definition


I have the following code

type Opaque<T,U> = T & {_:U};
type EKey = Opaque<number,'EKey'>;
type AKey = Opaque<EKey,'AKey'>;
type PKey = Opaque<AKey,'PKey'>;

let a = <PKey>1;
let b:EKey = a;

When I move over a, I'd like it to show PKey instead of Opaque<Opaque<Opaque<"EKey">,"AKey">,"PKey">.

enter image description here

Is there a way to do this using built-in vscode options or by writing my own vscode extension using the vscode API?


Solution

  • You can alter the quick info by writing your own typescript language server plugin and overwriting getQuickInfoAtPosition.

    https://github.com/Microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin