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?
2 Answers
What you do is destructing argument and assign property to new value, instead you should do this:
.map(({ key }: { key: any }) => key);
I would suggest to read more about TS in handbook
{ key:any }any will be treated as alias of key. use it something like this{ key }: { key: any }