Is it possible to simplify the type that is being shown in the type-tooltip that is visible when I hover over a variable in Typescript?
I have the following code:
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;
When I hover over result
variable I get:
[
However, when I hover over type X
I see:
Questions:
- Why are those types shown differently? (Even though they represent the same thing)
- Is there a way to show the type like it's shown in the second screen?