Let's consider a simplified instance (although overloading may not be necessary in this case due to the simplification)
UPDATE: The initial example provided did not fully illustrate the issue, so here is an improved version:
function fn <T>( // Overload signature is not compatible with function implementation.ts(2394)
fn: (item: T) => T,
): (idx: number) => (src: T[]) => T[]
function fn <T>(
fn: (item: T) => T,
idx: number,
): (src: T[]) => T[]
function fn(fn: (x: any) => any, idx?: number) {
}
How should the Return type be qualified in the implementation in this scenario?
I'm encountering a ts(2394)
error on the first definition and I'm unsure of what mistake I'm making.
Appreciate any help, Seb