实现 TypeScript 内置的工具类型 ReturnType<T> ,但不可以使用它。
ReturnType<T>
例如:
const fn = (v: boolean) => { if (v) { return 1 } else { return 2 } } type A = MyReturnType<typeof fn> // type A = "1 | 2"
TypeScript