【问题标题】:Type for parameter in TypeScript Arrow FunctionTypeScript 箭头函数中的参数类型
【发布时间】:2020-02-05 08:18:47
【问题描述】:

"noImplicitAny": true

TypeScript 会报错:

参数 'x' 隐含了一个 'any' 类型

.do(x => console.log(x));

和错误

',' 预期的

为:

.do(x: any => console.log(x));

【问题讨论】:

    标签: typescript


    【解决方案1】:

    经过一番搜索,我发现为参数定义类型的正确方法是添加括号:

    .do((x: any) => console.log(x));
    

    【讨论】:

      猜你喜欢
      • 2023-01-08
      • 1970-01-01
      • 2021-12-15
      • 2017-03-09
      • 2018-01-25
      • 2021-07-22
      • 2017-06-12
      • 1970-01-01
      • 2016-08-26
      相关资源
      最近更新 更多