Open jasonkuhrt opened 1 year ago
Maybe a few functions like Functions.MapArguments<Mapper>
and Functions.MapReturnType<Mapper>
could be added to support these use cases?
type DoStuff<Fn> = Pipe<Fn, [
// Remove a union member from the return type
Functions.MapReturnType<Union.Exclude<"a">>,
// add a union member to the return type
Functions.MapReturnType<Union.Append<"b">>,
// remove a parameter
Functions.MapArguments<Tuples.Filter<Boolean.Extends<number>>>,
// add a parameter
Functions.MapArguments<Tuples.Append<"1" | "2" | "3">>,
// map over the parameters
Functions.MapArguments<Tuples.Map<Strings.ToNumber>>,
]>
What do you think?
Potentially useful, yeah.
Going back to the Reselect MergeParameters
example I'd linked at https://github.com/reduxjs/reselect/blob/v4.1.5/src/types.ts#L100-L148 (and the updated version from Anders Hejlsberg at https://github.com/reduxjs/reselect/blob/b2a85eeac3312bb62ae3c26bb44d9aabd8641552/src/versionedTypes/ts47-mergeParameters.ts )... what might those look like with this style of typing?
Added Functions.MapParameters
and Functions.MapReturnType
to the latest release! let me know what you think
Examples:
Would this be in scope for this project?