Typescript: Object.keys must use keyof of generic type <T extends object>, not just <T>

Created on 4 Apr 2019  路  2Comments  路  Source: microsoft/TypeScript

Despite the comment https://github.com/Microsoft/TypeScript/pull/12253#issuecomment-263132208
I would proceed the discussion with just a little suggestion:

the Object.keys function should look like:
keys<T extends {}>(o: T): Array<keyof T>;

Duplicate

Most helpful comment

Duplicate and rejected multiple times: https://github.com/Microsoft/TypeScript/pull/12253#issuecomment-263132208, #30314, #13254. #30228, #28899, #28284, #26901.

More info

All 2 comments

Duplicate and rejected multiple times: https://github.com/Microsoft/TypeScript/pull/12253#issuecomment-263132208, #30314, #13254. #30228, #28899, #28284, #26901.

More info

Thanks @j-oliveras - much appreciated

Was this page helpful?
0 / 5 - 0 ratings