Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add objectEntries() #12

Merged
merged 4 commits into from
Nov 29, 2021
Merged

Add objectEntries() #12

merged 4 commits into from
Nov 29, 2021

Conversation

younho9
Copy link
Contributor

@younho9 younho9 commented Nov 26, 2021

Description

This adds a strongly-typed version of Object.entries() function.

Close #11

@sindresorhus sindresorhus merged commit bfbeff9 into sindresorhus:main Nov 29, 2021
```
*/
export function objectEntries<Type extends Record<PropertyKey, unknown>, Key extends `${Exclude<keyof Type, symbol>}`>(value: Type): Array<[Key, Type[Key]]> {
return Object.entries(value) as Array<[Key, Type[Key]]>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not Entries from type-test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entries of type-fest returns string | number type key. Object.entries stringify string | number key.

We need to discuss whether numeric key must be stringified or not. @jonahsnider

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: Strongly-typed version of Object.entries()
4 participants