Closed
Description
As far as I know, in Flow there are so called "generic meta types" that can operate on other types:
type C = $Merge<{a: number}, {b: string}>; // C = { a: number, b: string }
type A = $Args<(a: number, b: string) => void>; // A = [number, string]
Such "type algebra" would be useful to construct function signatures and interfaces that are hard/impossible to construct with other techniques:
interface TaggedFunction<Callable extends (...args) => any> {
type Args = $Args<Callable>;
type RetV = $RetV<Callable>;
(...args: ...Args): RetV;
tag: number;
bind<...T>(...args: ...T): TaggedFunction<(...args: $Concat<Args, ...T>) => RetV>;
}
Do you think this would be a useful addition to the type system?