#How to get the ReturnType of a function with a generic parameter
6 messages · Page 1 of 1 (latest)
I found this answer https://stackoverflow.com/questions/50321419/typescript-returntype-of-generic-function
But the problem is that I have a list of these functions, so i'd need to declare a new class for each of them, and Wrapper<T> wouldn't work any more because i'd have Wrapper1, Wrapper2, etc.
@oak stream Your original code does work though?
declare const testing: <T extends { a: number } | { b: number }>(
a: T,
) => T extends { a: number } ? 1 : 2
type Something = ReturnType<typeof testing<{ a: 1 }>>
// ^? - type Something = 1