-
-
Notifications
You must be signed in to change notification settings - Fork 545
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 RequireAtLeastOne
type
#1
Conversation
Extracted from sindresorhus/electron-util#11
I like AtLeastOne 😋 |
I don't think it's clear enough if we drop |
c662e89
to
2b47710
Compare
index.d.ts
Outdated
Omit<ObjectType, KeysType> | ||
& { | ||
[Key in KeysType]-?: Required<Pick<ObjectType, Key>> | ||
}[KeysType]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I'm asking a lot, but would you be able to describe in words how the type works in words? This can be very valuable to users reading this. We could use the opportunity to teach them.
|
||
/* | ||
Create a type that requires at least one of the given keys. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you be able to mention some real-world use-cases for this type? It can be hard sometimes for users to realize where they could take advantage of a certain type.
I just added some contribution guidelines. Would you be able to review them? I'm also interested in feedback if anything there is unclear or could be improved. https://github.com/sindresorhus/type-fest/blob/master/.github/contributing.md |
# Conflicts: # index.d.ts # index.test-d.ts
The contribution guidelines look great! 👍 Can't think of anything to add/change. |
Required<Pick<ObjectType, Key>> | ||
) | ||
}[KeysType] | ||
// …then, make intersection types by adding the remaining properties to each mapped type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great way to explain it 👌🙏
@CvX Would you be interested in joining as a maintainer? Just to help with reviews when you have time. |
Oh, and would you be able to make use of this type in |
Sure to both! 🙂 |
Awesome :) |
(Extracted from sindresorhus/electron-util#11)
I'm wondering if it would be better to change its name to just "AtLeastOne"… 🤔