I currently have this type:
type ReturnType<T, E> = [T, E]
I 'm trying to make this type "smarter" by these rules:
- If
Tisundefined, then the type would be[undefined, E] - If
Eisundefined, then the type would be[T] TandEcan't both beundefined
I'm trying to apply these rules using Typescript's Conditional Types.
Is this even possible to implement?
This is what I got so far:
type ReturnType<T, E> =
T extends undefined
? E extends undefined ? never : [undefined, E]
: E extends undefined ? [T] : never