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

Fix(prop): Allow optional props for prop(key)(obj) variety #75

Merged
merged 1 commit into from
Nov 15, 2023

Conversation

Harris-Miller
Copy link
Collaborator

The way prop(key)(obj) was typed was obj extends Record<K, unknown>. From typescript's point of view, this means that the object must contain the key, but not if the key was optional. The constraint that prop(key)(obj) should have is that if the key exists on obj, optional or not. To fix, Partial<Record<K, unknown>> should be used. But that's a lot of characters, { [P in K]?: unknown } is the exact same thing with less characters, so going with that

@Harris-Miller Harris-Miller mentioned this pull request Oct 18, 2023
@perrin4869
Copy link

just wondering, any reason this was not merged yet?

@Harris-Miller Harris-Miller merged commit 33e427c into develop Nov 15, 2023
3 checks passed
@Harris-Miller Harris-Miller deleted the prop-fix-for-optional branch November 15, 2023 03:24
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.

2 participants