I'm using TypeScript along with TSLint, and I have the following code:
var myObj = {}
var id = "key"
myObj[id] = 1
delete myObj[id]
But I receive a hint from TSLint: Do not delete dynamically computed property keys. (no-dynamic-delete)
The rationale for this rule (as stated on the documentation for TSLint):
Deleting dynamically computed keys is dangerous and not well optimized.
My question is, without disabling this hint in the TSLint configuration file, how should I safely and optimally delete the id
key in myObj
?