I have tried to read how to delete a property from an object in here: How do I remove a property from a JavaScript object?
it should use delete
, I try it like this
const eventData = {...myEvent}; // myEvent is an instance of my `Event` class
delete eventData.coordinate; // I have error in here
but I have error like this
The operand of a 'delete' operator must be optional.ts(2790)
and then I read this : Typescript does not infer about delete operator and spread operator?
it seems to remove that error is by changing my tsconfig.json file using
{
"compilerOptions": {
...
"strictNullChecks": false,
}
...
}
but if I implement this, I will no longer have null checking
so how to delete a property from an object in Typescript without the operand of a 'delete' operator must be optional error?