Implement the built-in ReturnType<T> generic without using it.
ReturnType<T>
For example
const fn = (v: boolean) => { if (v) return 1; else return 2; } type a = MyReturnType<typeof fn> // should be "1 | 2"
Code