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

Use generic for object-map Record key type #448

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sunnyzanchi
Copy link

This lets the function pass through more specific type information

✔️ Updated tests and yarn test-types passes

@angus-c
Copy link
Owner

angus-c commented Apr 30, 2022

Thanks! Is it possible for object key to be a number though? I think they can only be strings or symbols (all other values are automatically coerced to strings.

item: Record<string, T>,
callback: (key: string, value: T) => U
): Record<string, U>;
declare function map<K extends string | number | symbol, T, U = T>(
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think object keys can ever be numbers

Copy link
Author

Choose a reason for hiding this comment

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

hey! sorry for the late reply. you're right, that's my mistake. i updated the change to remove number from the type

This lets the function pass through more specific type information
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants