无法将类型“ LodashReplace1x5”分配给类型“字符串”

时间:2020-05-02 11:13:37

标签: typescript vuejs2 type-conversion lodash

我在打字稿中使用lodass / fp有一个奇怪的问题。它有效,但显示错误。我不知道为什么会这样。

这是错误:

TS2769: No overload matches this call.   Overload 1 of 3, '(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string', gave the following error.     Argument of type '(acc: string, curr: string) => fp.LodashReplace1x5' is not assignable to parameter of type '(previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string'.       Type 'LodashReplace1x5' is not assignable to type 'string'.   Overload 2 of 3, '(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string', gave the following error.     Argument of type '(acc: string, curr: string) => fp.LodashReplace1x5' is not assignable to parameter of type '(previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string'.       Type 'LodashReplace1x5' is not assignable to type 'string'.

出什么问题了?我该如何解决?

enter image description here

1 个答案:

答案 0 :(得分:0)

我以为它将检测类型,但是似乎我们必须明确地告诉类型,如您在下图中看到的那样:

enter image description here