Typescript: change function type so that it returns new value

Edit Since the original question was answered typescript has improved the possible solution to this problem. With the addition of Tuples in rest parameters and spread expressions we now don’t need to have all the overloads: type ReplaceReturnType<T extends (…a: any) => any, TNewReturn> = (…a: Parameters<T>) => TNewReturn; Not only is this shorter but … Read more