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 OneOrMore and NOrMore types #287

Closed
wants to merge 5 commits into from

Conversation

darcyparker
Copy link
Contributor

@darcyparker darcyparker commented Oct 12, 2021

Depends on #284 being fixed.

This is still a draft. You can see I inlined @jonahsnider's improved FixedLengthArray. (It does not work with existing FixedLengthArray)

index.d.ts Outdated
@@ -28,6 +28,7 @@ export {ConditionalPick} from './source/conditional-pick';
export {UnionToIntersection} from './source/union-to-intersection';
export {Stringified} from './source/stringified';
export {FixedLengthArray} from './source/fixed-length-array';
export {OneOrMore, NOrMore} from './source/n-or-more';
Copy link
Owner

Choose a reason for hiding this comment

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

The naming on the second one is a bit unfortunate. I keep reading it as no-r-more.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would AtLeastOne and AtLeastN be better names? Or maybe MoreThanN?

Copy link
Owner

Choose a reason for hiding this comment

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

Would AtLeastOne and AtLeastN be better names?

Yes

Or maybe MoreThanN?

This has a different meaning than NOrMore. (> vs >=)

Copy link
Owner

Choose a reason for hiding this comment

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

How about NonEmpty?

It could be NonEmpty and MinimumN.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like NonEmpty and MinimumN. See 446e3c5.

readme.md Outdated
@@ -121,6 +121,8 @@ Click the type names for complete docs.
- [`FixedLengthArray`](source/fixed-length-array.d.ts) - Create a type that represents an array of the given type and length.
- [`MultidimensionalArray`](source/multidimensional-array.d.ts) - Create a type that represents a multidimensional array of the given type and dimensions.
- [`MultidimensionalReadonlyArray`](source/multidimensional-readonly-array.d.ts) - Create a type that represents a multidimensional readonly array of the given type and dimensions.
- [`OneOrMore`](source/n-or-more.d.ts) - Create a type of one or more items.
Copy link
Owner

Choose a reason for hiding this comment

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

I prefer using the word "elements" over "items", so we should use that consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 446e3c5

@@ -0,0 +1,31 @@
/**
Create a type of one or more items.

Copy link
Owner

Choose a reason for hiding this comment

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

Need to mention use-cases and a usage example.

@darcyparker
Copy link
Contributor Author

FYI: I updated this pull request based on feedback (and after being MIA for a bit). I still need to add use cases and a usage example. I will do this after #294 is finalized/merged. Because this draft should be updated to use the updated FixedLengthArray (or a new flavour of it is merged to main).

readme.md Outdated
Comment on lines 149 to 150
- [`NonEmpty`](source/minimum-n.d.ts) - Create a type of one or more elements.
- [`MinimumN`](source/minimum-n.d.ts) - Create a type of N or more elements.
Copy link
Contributor

Choose a reason for hiding this comment

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

This sounds like it's describing a union type, you should explicitly mention that this is an array type.

/**
Create a type of one or more elements.

@category Utilities
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@category Utilities
@category Array

Categories were made more specific in #331

@sindresorhus
Copy link
Owner

Seeing as this is blocked by #284 and that issue is not going anywhere, what should we do about this pull request?

@darcyparker
Copy link
Contributor Author

A solution is now feasible with ReadonlyTuple which was implemented #383 It is not blocked by #284.

I need to come back to this. I am sorry I have let this sit. I am fine if you kill this PR until I am able to get back to it.

@sindresorhus
Copy link
Owner

Ah ok. That's good news. I can keep the PR open for a couple of months more.

This was referenced Sep 29, 2022
@sindresorhus
Copy link
Owner

Closing for lack of activity.

Moved this into two issues:

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.

None yet

3 participants