It seems challenging to provide a definite definition for that.
Upon reviewing the lodash type declaration file, it appears they do not attempt to articulate such a relationship.
interface LoDashStatic {
flow<TResult extends Function>(...funcs: Function[]): TResult;
}
Nevertheless, this does not conclusively rule out the possibility. It is plausible that the authors may have overlooked certain aspects, prompting us to delve further into the topic.
The concept of representing the relationship within an individual chain of functions is feasible. This has been exemplified in your provided instance. While manual versions can be created for varying parameter lengths when the chain length is predetermined, maintaining individual type information is crucial.
In scenarios involving variable length parameters, treating them as a Collection becomes imperative. Every variable needs to adhere to a singular (albeit potentially parameterized) type, but discrepancies arise with different function types, making storage within a well-typed container challenging.
To preserve type information concerning a parameter list like this, it is common practice to define a composition function between two parameters and apply it across multiple functions. This approach mirrors how promises retain type data. Although explicit parameter definitions are necessitated, the desired output type is eventually achieved, aligning with typical requirements.
If lodash were developed using a strongly-typed functional language, the existence of the flow function might be substituted with a piped composition object instead.
UPDATE: When referring to a "piped composition object," envision something along these lines:
class FunctionComposer<T,V> {
constructor(protected func: (param: T) => V) { }
public compose<X>(newFunc: (param:V) => X) {
return new FunctionComposer((x: T) => newFunc(this.func(x)));
}
public out() {
return this.func;
}
}
let composedFunc = new FunctionComposer((x: number) => x * 2)
.compose(x => x.toString())
.out();
// composedFunc has type (param:number) => string