如果我有一个看起来有点像这样的类型集合,只会更详细:
type ValidValues = string | number | null
type ValidTypes = "text" | "time" | "unknown"
type Decorated = {
name?: string | null
type?: ValidTypes
value?: ValidValues
title: string
start: number
}
type Injected = {
extras: object
}
// overriding the types from Decorated
type Text = Decorated & Injected & {
name: string
type: "text"
value: string
}
Run Code Online (Sandbox Code Playgroud)
我的实际代码还有更多内容,但这显示了核心思想。我不想必须相信自己才能使类型之间的关系恰到好处。Text
在所有类型代数之后,我想要工具向我展示“评估”的类型定义。
因此,对于上面的示例,我希望 中指定的字段Text
将覆盖该Decorated
类型中先前的声明,并且我假设的工具提示的输出(我希望)会显示如下内容:
{
name: string
type: "text"
value: string
title: string …
Run Code Online (Sandbox Code Playgroud) 当我在 VS Code 中创建任何界面时,界面内没有任何方法的预览。当我使用类型声明时,它会按预期工作。
interface SomeInterface {
someMethod: string
}
let test: SomeInterface = {
};
Run Code Online (Sandbox Code Playgroud)
我知道(并同意)此处描述的行为,但是,这似乎对我不起作用。
我尝试在方法上方创建 JSDoc 描述(未显示描述或方法)。
目前的解决方法:
peek
跳转到接口声明。