Is it feasible to generate a type alias for an overloaded function signature?
For instance, I have a function as follows:
function whenChanged(scope: ng.IScope, fn: ()=>void): ()=>void;
function whenChanged(fn: ()=>void, truthy:any): ()=>void;
function whenChanged(a,b): ()=>void {
//...
}
I aim to establish a type alias for that overloaded signature in order to minimize redundancy and utilize it elsewhere while describing this function's type.
I attempted:
type WC1 = (scope: ng.IScope, fn: ()=>void) => ()=>void;
type WC2 = (fn: ()=>void, truthy:any) => ()=>void;
type WhenChanged = WC1 | WC2;
const whenChanged: WhenChanged = (a,b) => {
//...
};
However, attempting to use this function leads to an error stating "Cannot invoke an expression whose type lacks a call signature".
I am unable to find any information in the documentation regarding type aliasing function overloads.