是否有可能简化的类型,正在显示在类-提示也就是可见的,当我悬停在一个变量的稿?
我有下列代码:
type Debug<T> = {
[key in keyof T]: T[key]
}
type Chainable<Acc = {}> = {
option: <K extends string, V>(key: K, value: V) => Chainable<Acc & {[k in K]: V}>;
get: () => Debug<Acc>;
}
declare const config: Chainable
const result = config
.option('foo', 123)
.option('name', 'type-challenges')
.option('bar', { value: 'Hello World' })
.get()
type X = typeof result;
当我悬停 result
变我获得:
[
问题:
- 为什么是那些类型所示的有所不同? (即使他们代表了同样的事情)
- 有一种方式来显示的类型喜欢它显示在第二屏幕上?