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 RequireAtLeastOne type #1

Merged
merged 8 commits into from
Mar 18, 2019

Conversation

CvX
Copy link
Contributor

@CvX CvX commented Mar 13, 2019

(Extracted from sindresorhus/electron-util#11)

I'm wondering if it would be better to change its name to just "AtLeastOne"… 🤔

@tonivj5
Copy link

tonivj5 commented Mar 13, 2019

I like AtLeastOne 😋

index.d.ts Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

I don't think it's clear enough if we drop Require.

index.d.ts Outdated
Omit<ObjectType, KeysType>
& {
[Key in KeysType]-?: Required<Pick<ObjectType, Key>>
}[KeysType];
Copy link
Owner

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.

Copy link
Owner

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.

@sindresorhus
Copy link
Owner

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

@sindresorhus sindresorhus changed the title Add RequireAtLeastOne type Add RequireAtLeastOne type Mar 14, 2019
@CvX
Copy link
Contributor Author

CvX commented Mar 16, 2019

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.
Copy link
Owner

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 👌🙏

@sindresorhus sindresorhus merged commit d969311 into sindresorhus:master Mar 18, 2019
sindresorhus pushed a commit that referenced this pull request Mar 18, 2019
@sindresorhus
Copy link
Owner

@CvX Would you be interested in joining as a maintainer? Just to help with reviews when you have time.

@sindresorhus
Copy link
Owner

Oh, and would you be able to make use of this type in electron-util now?

@CvX
Copy link
Contributor Author

CvX commented Mar 18, 2019

Sure to both! 🙂

@sindresorhus
Copy link
Owner

Awesome :)

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.

3 participants