【问题标题】:How to understand this currying function with typescript interface如何用打字稿界面理解这个柯里化函数
【发布时间】:2019-11-23 07:06:35
【问题描述】:

我想我有点懂currying function。我对(response: any) => ITest = (response) 中的= 感到困惑

谁能解释一下?

更多代码

export interface ITest {
    type: string;
    payload: any;
}

export const callApi: (response: any) => ITest = (response) => ({
    type: 'CALL_API',
    payload: response
});

更新 1:

我试着一步一步写,对吗?

export const callApi: (response: any) => ITest

那么这个赋值给接口呢?

(response) => ({
  type: 'CALL_API',
  payload: response
})

【问题讨论】:

  • 这里没有柯里化。只是一个变量声明和初始化。
  • 这不是函数柯里化,(response: any) => ITest 是一个类型。 = 之后是函数
  • 我是export const <name>: <type> = <value>
  • “是否正确” - 编译器说了什么?

标签: typescript ecmascript-6


【解决方案1】:

= 是将值(在本例中为函数)分配给变量 callApi。只是。没有别的了

【讨论】:

  • 你能一步步写出来吗?
猜你喜欢
  • 1970-01-01
  • 2019-11-18
  • 2018-01-24
  • 1970-01-01
  • 1970-01-01
  • 2018-04-18
  • 1970-01-01
  • 2019-03-26
  • 2016-01-01
相关资源
最近更新 更多