I have an object
const person = {
first: 'John',
last: 'Doe',
id: 1,
}
I want to delete keys from person object. So in JavaScript it works
['first', 'last'].forEach((i) => {
delete person[i]
})
Error(From editor VSCode not compiled)
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ first: string; last: string; id: number; }'.
No index signature with a parameter of type 'string' was found on type '{ first: string; last: string; id: number; }'.ts(7053)
But in TypeScript it shows error. What will be the equivalent code in TypeScript. Thanks.