microsoft/TypeScript

Change signature of Object.keys to return (keyof T)[]

iansan5653 opened this issue · 4 comments

This seems like a simple thing, although I know there's probably a reason it's not already like this.

Currently the signature of Object.keys is:

{
  keys(o: object): string[];
}

But why not make it more specific?:

{
  keys<T extends object>(o: T): (keyof T)[];
}

Please respect the issue templates for bug reports and feature requests.

Both issue templates ask you to search for existing issues before opening a new one.


This is a duplicate and has been rejected multiple times: #12253 (comment), #30314, #13254. #30228, #28899, #28284, #26901, #30749, #31087, #32321, #34498, #35145.

more info

@MartinJohns I'm becoming worried that listing all the duplicates is resulting in an O(n^2) usage of GitHub's storage 😅

Considering how often this and similar questions are asked I have absolutely no doubt that Microsoft / GitHub will run of space in no time!