Reputation:
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?
Upvotes: 1
Views: 94
Reputation: 532
const array: any = [{ test: 10 }, { test: 'test' }, {test: true}];
console.log(array.map(({ test }: {test: any}) => test));
output : [10, "test", true]
Upvotes: 0