【发布时间】:2020-10-25 13:44:51
【问题描述】:
我收到错误:Expected 1 arguments, but got 2.ts(2554) 当我将方法的非咖喱定义放在咖喱定义之上时。
dtslint 测试失败:
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
})
如果我将 curried match 定义移到 uncurried 定义之上,那么错误就会消失。
我的问题是我是否应该将非curried版本放在curried版本之后,还是throttle定义中有错误?
问题的上下文是为类似于ramda 的库编写 Typescript 定义。
【问题讨论】:
标签: typescript definitelytyped