Upon placing the uncurried definition of a method above the curried definition, I encountered an error stating:
Expected 1 arguments, but got 2.ts(2554)
.
The dtslint
test that failed reads as follows:
function match(regExpression: RegExp, str: string): string[];
function match(regExpression: RegExp): (str: string) => string[];
function throttle<T, U>(fn: (input: T) => U, ms: number): (input: T) => U;
function throttle<T, Q, U>(
fn: (input1: T, input2: Q) => U, ms: number
): (input1: T, input2: Q) => U;
it('match', () => {
const fn = throttle(match, 1000)
fn(/foo/,'foo bar') // line of error
})
I noticed that if I move the curried match
definition above the uncurried one, the error disappears.
My inquiry is whether it is preferable to place the uncurried version after the curried one, or if there might be an issue within the throttle
definition?
This question pertains to crafting Typescript definitions for a library akin to ramda
.