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

Created on 20 Mar 2020  ·  4Comments  ·  Source: microsoft/TypeScript

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)[];
}
Duplicate

Most helpful comment

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

All 4 comments

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: https://github.com/microsoft/TypeScript/pull/12253#issuecomment-263132208, #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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kyasbal-1994 picture kyasbal-1994  ·  3Comments

fwanicka picture fwanicka  ·  3Comments

zhuravlikjb picture zhuravlikjb  ·  3Comments

wmaurer picture wmaurer  ·  3Comments

blendsdk picture blendsdk  ·  3Comments