Skip to content

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

@iansan5653

Description

@iansan5653

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions