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

RequireOnlyOne #290

Closed
alita-moore opened this issue Oct 13, 2021 · 6 comments
Closed

RequireOnlyOne #290

alita-moore opened this issue Oct 13, 2021 · 6 comments

Comments

@alita-moore
Copy link

alita-moore commented Oct 13, 2021

Not sure how to do this right now, but is there a type already available for doing the same thing as RequireAtLeastOne but instead for RequireOnlyOne? I'm running into a problem where I want to require a partial object with only one member. Is there any easy way to do this or is this a type you think would be useful/

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • The funding will be given to active contributors.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@darcyparker
Copy link
Contributor

See draft: #287

export type OneOrMore<T> = [T, ...T[]]; // NOrMore<T, 1>

If you want to require exactly one: type RequireOnlyOne<T> = [T] (Not sure you need a type for this...)

@alita-moore
Copy link
Author

ncie

@sindresorhus
Copy link
Owner

If you want to require exactly one: type RequireOnlyOne = [T] (Not sure you need a type for this...)

I think we should document that as a tip in the readme.

@sindresorhus
Copy link
Owner

Why are you closing? This is not resolved.

@sindresorhus sindresorhus reopened this Oct 18, 2021
@alita-moore
Copy link
Author

I closed due to the fact this is included in darcy's draft #287

@tommy-mitchell
Copy link
Contributor

RequireExactlyOne?

Emiyaaaaa pushed a commit to Emiyaaaaa/type-fest that referenced this issue Aug 26, 2023
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

No branches or pull requests

4 participants