I have a function signature that is used across multiple interfaces and sufficiently complex for me to put into a separate type definition:
type LongSignature = (a: string, b: string, c: string, d: string, e: string, f: string) => number
When I try to use that signature for an overload I get an error:
interface F {
f (a: string): number
f: LongSignature // Subsequent property declarations must have the same type. Property 'f' must be of type '(a: string) => number', but here has type 'LongSignature'.(2717)
}
One way to overcome this is to rewrite all methods as arrow functions and express the overloads via intersection type:
interface G {
g: ((a: string) => number) & LongSignature
}
As the actual code is far more complex and has a lot of overloads, this becomes ugly really quick. So I'd really prefer the syntax I presented for F. Can this be done?
Side note: the functions within each interface have the same signature but different names (see F.f vs G.g). So I can not resolve this via inheritance.