consider this type and this generic:
type Data = { item: number };
type Generic<T> = {
obj: T;
};
now this is an instance of it:
const test: Generic<Data> = { obj: { item: 0 } };
now what I really need when using test.obj
is to see the type for obj (Data
) when clicking on it, not it's type in the Generic (T
)
When clicking on test.obj
What I expected:
to go to Data
type definition
type Data = { item: number };
What happend:
it went to its definition in the generic T
type Generic<T> = {
obj: T;
};
so is this possible?
CodePudding user response:
If I understand the question, "simply" don't annotate your variable.
If you really must and you can use TS 4.9, use satisfies
instead:
const test = { obj: { item: 0 } } satisfies Generic<Data>;