简体   繁体   English

Vscode Typescript:显示类型的别名,而不是其定义

[英]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"> . 当我移过a ,我希望它显示PKey而不是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? 有没有办法使用内置的vscode选项或通过使用vscode API编写我自己的vscode扩展来做到这一点?

You can alter the quick info by writing your own typescript language server plugin and overwriting getQuickInfoAtPosition . 您可以通过编写自己的打字稿语言服务器插件并覆盖getQuickInfoAtPosition来更改快速信息。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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