typescript - io-ts 对象类型名称在 WebStorm 中丢失
问题描述
我想使用 io-ts 来验证输入。然而,与接口类型相比,WebStorm/IDEA 在将鼠标悬停在类型上时不会显示对象类型的名称,而是显示类型本身的详细信息。
假设我们有以下代码,一个 io-ts 用户和一个界面用户。
import * as t from 'io-ts';
const UserType = t.type({
name: t.string,
});
type User = t.TypeOf<typeof UserType>;
interface UserI {
name: string;
}
const myUserI: UserI = { name: 'Paul' }; //WebStorm Type const myUserI: UserI
const myUserIoTs: User = { name: 'Luna' }; //WebStorm Type const myUserIoTs: { name : string }
当我将鼠标悬停在 myUserI 上时,WebStorm 显示的类型信息是const myUserI: UserI
但是,当我将鼠标悬停在 myUserIoTs 类型上时,WebStorm 显示的信息const myUserIoTs: {name: string;}
不是const myUserIoTs:User
WebStorm 有没有办法显示类型名称User
而不是{name: string}
?
解决方案
当您将ctrl
鼠标悬停在 TypeScript 文件中的符号上时,您在 WebStorm 中看到的工具提示显示了从 TypeScript 编译器服务推断的类型信息。TypeScript 本身为接口和枚举与类型别名提供的信息确实存在已知差异。这是 TypeScript 跟踪器上的一个问题:https ://github.com/microsoft/TypeScript/issues/25894
推荐阅读
- php - vscode在Homestead环境下无法远程调试php代码但我前一天可以调试
- json - 将 Keenio 数据提取到谷歌电子表格中
- c++ - 两次模板
宣言 - java - 从节点调用 EJB 客户端
- angular - Angular 6,无法绑定到“org”,因为它不是“appCycleDirection”(指令)的已知属性
- elasticsearch - Scrapy 到 elasticsearch 批量导入?
- linux - 从 Bluez 5.48 开始如何写入特征
- c# - 使用 StackTrace 获取调用方法
- sql - SQL 错误 - “列定义不明确”
- python - Python将类和函数从一个文件导入另一个文件