-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Object.keys should return keyof T
#32321
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
Comments
Already rejected multiple times, search for Object.keys |
In some specific instances, it will. In most others, it will not. declare const x : { a : number };
Object.keys(x); You might expect the above to return Because If anything, we can only say
I'm sure there are other constraints I haven't thought of. [Edit] |
Maybe we should make a template just for this. It'd save people a lot of time. |
@RyanCavanaugh I actually just copied my last comment and added the other issue. But this is a good candidate for the FAQ (but I doubt it's being checked before). |
It’s because it sounds so obvious that I just checked the open issues before opening this one 😅 Nobody expects |
TypeScript Version: 3.6.0-dev.20190717
Code
Expected behavior:
Actual behavior:
Workaround:
Playground Link: https://www.typescriptlang.org/play/#src=const%20feature%20%3D%20%7B%0D%0A%09description%3A%20''%2C%0D%0A%09screenshot%3A%20''%2C%0D%0A%09disabled%3A%20''%0D%0A%7D%3B%0D%0A%0D%0Aconst%20keys%20%3D%20Object.keys(feature)%3B
The text was updated successfully, but these errors were encountered: