We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
keyof any
string
keyof any string
Tested in the playground on "v3.3.3333" and "Nightly", it occurs in both versions
https://www.typescriptlang.org/play/?ts=5.8.0-dev.20250217#code/FAFwngDgpgBA8gIwFYwLwwN4wNoGsYCWAdjLlGAPYBmMAhkWALoBcMRArgLYJQBOMAX2AB6YTHEA9APzBQkWAGlyAZzSly1eMgDcIsZJnAAJlADGAG1q9YpikWUgYFZK0RJdzpNgDKYbhXMAOgIQPloQCl5GGFEYAAoAFQALAlUEa1pcZQBKIA
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)
The Obj type allows indexing only with strings
Obj
The Obj type should allow indexing with every type of property key
No response
The text was updated successfully, but these errors were encountered:
any
T extends unknown
T
I came across a relevant comment that may be of interest to anyone looking at this issue.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
π 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
Obj
type allows indexing only with stringsπ Expected behavior
The
Obj
type should allow indexing with every type of property keyAdditional information about the issue
No response
The text was updated successfully, but these errors were encountered: