-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
Bug Report
π Search Terms
Object key type, index signature parameter type
π Version & Regression Information
- This is the behavior in every version I tried, and I believe it should act differently
β― Playground Link
Playground link with relevant code
π» Code
const a: {[prop: number]: number} = {};
a[1] = 123;
for (const i in a) {
console.log(a, a[i], typeof i);
}
π Actual behavior
I'm allowed to set the prop
key to type number
, but it is actually a string
when tested
π Expected behavior
It should not allow me to use number
as the type for the key properties as it automatically converts to string
anyways which could create confusion
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug