π Search Terms
keyof any string
π Version & Regression Information
Tested in the playground on "v3.3.3333" and "Nightly", it occurs in both versions
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.8.0-dev.20250217#code/FAFwngDgpgBA8gIwFYwLwwN4wNoGsYCWAdjLlGAPYBmMAhkWALoBcMRArgLYJQBOMAX2AB6YTHEA9APzBQkWAGlyAZzSly1eMgDcIsZJnAAJlADGAG1q9YpikWUgYFZK0RJdzpNgDKYbhXMAOgIQPloQCl5GGFEYAAoAFQALAlUEa1pcZQBKIA
π» Code
type Obj = { [k in keyof any]: number }
// ^? type Obj = { [x: string]: number; }
type Keys = keyof Obj;
// ^? type Keys = string | number | symbol
declare const obj: Obj;
obj[Symbol.iterator] // (This breaks)
π Actual behavior
The Obj type allows indexing only with strings
π Expected behavior
The Obj type should allow indexing with every type of property key
Additional information about the issue
No response
π Search Terms
keyof any string
π Version & Regression Information
Tested in the playground on "v3.3.3333" and "Nightly", it occurs in both versions
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.8.0-dev.20250217#code/FAFwngDgpgBA8gIwFYwLwwN4wNoGsYCWAdjLlGAPYBmMAhkWALoBcMRArgLYJQBOMAX2AB6YTHEA9APzBQkWAGlyAZzSly1eMgDcIsZJnAAJlADGAG1q9YpikWUgYFZK0RJdzpNgDKYbhXMAOgIQPloQCl5GGFEYAAoAFQALAlUEa1pcZQBKIA
π» Code
π Actual behavior
The
Objtype allows indexing only with stringsπ Expected behavior
The
Objtype should allow indexing with every type of property keyAdditional information about the issue
No response