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
I ran into a scenario yesterday that surprised me a bit. I was using an object literal to store some unique keys that I later extracted with a for-in loop. The keys were all numbers, but I quickly ran into a problem at runtime because i had forgotten that JavaScript coerces number type keys to strings for objects.
To wit, given the coercion of keys to strings, I was surprised that this type checked:
I ran into a scenario yesterday that surprised me a bit. I was using an object literal to store some unique keys that I later extracted with a for-in loop. The keys were all numbers, but I quickly ran into a problem at runtime because i had forgotten that JavaScript coerces number type keys to strings for objects.
To wit, given the coercion of keys to strings, I was surprised that this type checked:
Is this expected behavior, or should this throw a compile time warning?
(TSC Version 1.7.5)
The text was updated successfully, but these errors were encountered: