-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
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
Change type definition of Object.keys and for..in loop #24243
Comments
Yep, that works out of the box:
|
5 tasks
10 tasks
7 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Search Terms
Object.keys, index signature
Suggestion
Currently the definition of Object.keys in lib.d.ts is
keys(o: {}): string[];
why not change to
keys<T extends Object>(o: T): Array<keyof T>
and accordingly change for ... in loop
Use Cases
It is ridiculous that code like
const a = {}
Object.keys(a).forEach(key => a[key])
will raise a 'has no index signature' error
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: