In my function, the first argument now determines if the function should receive an array or not.
This function is similar to Foo
type stringF = (arr: false, type: 'str', value: string) => void
type numberF = (arr, false, type: 'num', value: number) => void
type booleanF = (arr, false, type: 'bool', value: boolean) => void
...
...
declare const Foo: stringF & numberF & booleanF //& etc..
Initially there were 6 function types, which was manageable. But with the addition of an extra parameter determining array usage, things have become more complex.
Now the function types are:
type stringF = (arr: true, type: 'str', value: string[]) => void
type numberF = (arr, true, type: 'num', value: number[]) => void
type booleanF = (arr, true, type: 'bool', value: boolean[]) => void
...
Now there are 12 function types, and it seems challenging to properly type each function.
Is there an easier way to handle conditional function signatures?