首页 > 解决方案 > Vscode Typescript:显示类型的别名而不是其定义

问题描述

我有以下代码

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;

当我移动时a,我希望它显示PKey而不是Opaque<Opaque<Opaque<"EKey">,"AKey">,"PKey">

在此处输入图像描述

有没有办法使用内置的 vscode 选项或使用 vscode API 编写我自己的 vscode 扩展来做到这一点?

标签: typescriptvisual-studio-codevscode-extensions

解决方案


您可以通过编写自己的打字稿语言服务器插件和覆盖来更改快速信息getQuickInfoAtPosition

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


推荐阅读