-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already createdNeeds ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript
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?
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already createdNeeds ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript