I have a generic interface available to me as such:
CurriedFunction3<T1, T2, T3, R>: R
I would like to create a const binding that fills in some of those type arguments. Something like this:
type CurriedSorter<T> = CurriedFunction3<(obj: T) => any, string, T[], T[]>;
When I try to assign a const
binding this type, however, I get an error:
type CurriedSorter<T> = CurriedFunction3<(obj: T) => any, string, T[], T[]>;
const sortFactory: CurriedSorter = uncurryN(3, flip(compose(
unapply(sortWith),
uncurryN(2, ifElse(
compose(equals('DESC'), toUpper),
always(descend),
always(ascend),
)),
)));
Generic type
CurriedSorter
requires 1 type argument(s).
The const
binding sortFactory
should be a function with one generic type parameter, to be used as such:
sortFactory<MyType>(
prop('name'),
'DESC',
[{ name: 'foo' }, { name: 'bar' }]
) // returns `[{ name: 'bar' }, { name: 'foo' }]`
How can I generically type variable bindings in TypeScript? Is there any way to do this with TypeScript?