I'm trying to create a type declaration that excludes the return union type, but I'm facing an issue. Here's how it looks:
export type ExcludeReturnType<T extends (...args: any[]) => any, R> = (...args: any) => Exclude<ReturnType<T>, R>
type Orig = (a: number) => string | void
type Result = ExcludeReturnType<Orig, void> // (...args: any[]) => string
type Expected = (a: number) => string
The problem is that the parameters are all turning into any[]
. I need help preserving the original function's type. Any suggestions?