【问题标题】:Type 'LodashReplace1x5' is not assignable to type 'string'类型“LodashReplace1x5”不可分配给类型“字符串”
【发布时间】:2020-05-02 11:13:37
【问题描述】:

我在打字稿中使用 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'.

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

【问题讨论】:

    标签: typescript vuejs2 type-conversion lodash


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2021-02-22
      • 2020-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多