You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I declare an index like this:
let index: {[index: number]: string} = {};
Then I can add a member to the index like this:
index['3s'] = 3;
The type of the key '3s' is string. But this works. Is this a bug?
The text was updated successfully, but these errors were encountered:
Lcng
changed the title
Index Bug?
Index which's key's type is number can accept string keys
Jan 14, 2018
JavaScript objects coerce numeric indices to strings behind the scenes, leading to some modeling challenges for TypeScript. See some of the related issues for further explanation: #17191, #13715, #12425.
When I declare an index like this:
let index: {[index: number]: string} = {};
Then I can add a member to the index like this:
index['3s'] = 3;
The type of the key '3s' is string. But this works. Is this a bug?
The text was updated successfully, but these errors were encountered: