如果我有一个看起来有点像这样的类型集合:
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
}
我的实际代码还有更多事情要做,但这显示了核心思想。 我不想只是相信自己能够准确地理解类型之间的关系。我希望工具可以向我展示经过所有类型代数运算后Text
类型定义的“计算”结果。
因此,对于上面的示例,我希望在Text
中指定的字段将覆盖在Decorated
类型中先前声明的内容,并且假设一个虚构的工具提示的输出将向我显示类似于:
{
name: string
type: "text"
value: string
title: string
start: number
extras: object
}
有没有方便的方式获取这些信息?