I may be asking a question that has already been answered, but I couldn't find the solution so here goes:
The workaround I have is not ideal because if I need to add more types, it will make upgrading difficult. Is there a better way to approach this?
declare const max: <A extends number | string> (a: A) => (b: A) => A
max(2)(3) // Argument of type '3' is not assignable to parameter of type '2'
max('a')('b') // Argument of type '"b"' is not assignable to parameter of type '"a"'
// Possible workaround but will become clumsy if possible type to extends grow
declare const maxClumsy: {
(a: number): (b: number) => number
(a: string): (b: string) => string
}
maxClumsy(2)(3)
maxClumsy('a')('b')