I have a function where TypeScript can infer the return type based on the type of the input parameters.
//typescript can automatically infer the type of "result"
let result = handle(container, child);
The function also allows you to specify the type of the input functions explicitly using generics.
//you can also specify the types using generics:
let result = handle<MyContainer, MyChild>(container, child);
Is it possible to skip over the declaration of MyContainer
and only specify the second parameter MyChild
, while having TypeScript still determine the type of the first parameter without me specifying it:
let result = handle<skipMe, MyChild>(container, child);
What can I put in place of skipMe
? I can’t put unknown
or any
because then TypeScript thinks the type of the first parameter is any
.