Skip to content

Conversation

@LAITONEN
Copy link

Reason: https://stackoverflow.com/questions/51446585/type-array-of-keys-of-a-particular-interface

In short, with the current type of Object.keys: keys(o: {}): string[], typescript does not know what the values of o are, so if I pass Object.keys from a parent React.Component to a child and type definition of this particular child's prop is specified as (keyof InterfaceOfO)[], I get a `TypeError: Type 'string[]' is not assignable to type '("whatever" | "keys" | "of" | "o" | "are")[].

Fixes #

LAITONEN added 2 commits July 20, 2018 20:12
Reason: https://stackoverflow.com/questions/51446585/type-array-of-keys-of-a-particular-interface

In short, with the current type of Object.keys: `keys(o: {}): string[]`, typescript does not know what the values of `o` are, so if I pass Object.keys from a parent React.Component to a child and type definition of this particular child's prop is specified as `(keyof InterfaceOfO)[]`, I get a `TypeError: Type 'string[]' is not assignable to type '("whatever" | "keys" | "of" | "o" | "are")[].
Object.values has 2 type definitions: https://github.com/Microsoft/TypeScript/blob/master/lib/lib.es2017.object.d.ts
This commit returns the current type definition of Object.keys, adding it in addition to the proposed one in attempt to resolve the "non-successful checks" reported by the bot.
@j-oliveras
Copy link
Contributor

See #12870, #13971, #24243 and others (search object.keys).

@mhegazy mhegazy closed this Jul 20, 2018
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants