I'm trying to iterate through the key/value pairs in an object and in some cases want to overwrite some of them. To do that, I need to index into the object using the key, which is a string.
This works:
obj['a'] = 'new value';
This doesn't work:
obj[key] = 'new value';` //despite key being a string of value 'a'
The error 'string can't be used to index' can't be correct when it was happy to accept a hard-coded 'a' as an index.
Here's a screenshot from a simplified version of my code from the TypeScript playground. I'm working around this using @ts-ignore
currently but I really wish I didn't have to.