首页 > 解决方案 > Use Typescript in ReactJs

问题描述

I want to write this code: .map(({ key }) => key); using typescript, i did this: .map(({ key:any }) => key);, but i got an error: 'any' is declared but its value is never read.. How to apply typescript in my situation?

标签: reactjstypescript

解决方案


您所做的是破坏参数并将属性分配给新值,而不是您应该这样做:

.map(({ key }: { key: any }) => key);

我建议在手册中阅读有关 TS 的更多信息


推荐阅读