繁体   English   中英

类型“LodashReplace1x5”不可分配给类型“字符串”

[英]Type 'LodashReplace1x5' is not assignable to type 'string'

我在 typescript 中使用 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'.

问题是什么? 我该如何解决?

在此处输入图像描述

我认为它会检测到类型,但似乎我们必须明确地告诉类型,如下图所示:

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM