简体   繁体   中英

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"> .

在此处输入图片说明

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM