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

Like Promisable<X> but for arrays: X | X[] #270

Closed
fregante opened this issue Sep 22, 2021 · 3 comments · Fixed by #935
Closed

Like Promisable<X> but for arrays: X | X[] #270

fregante opened this issue Sep 22, 2021 · 3 comments · Fixed by #935

Comments

@fregante
Copy link
Collaborator

fregante commented Sep 22, 2021

I remember seeing this type somewhere, but I can't find it. Does it exist? Is it native?

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
@voxpelli
Copy link
Collaborator

Like a MaybeArray<X>?

type MaybeArray<X> = X|Array<X>;

Can't remember seeing it somewhere, but I do believe I have created such helpers in some projects.

@fregante
Copy link
Collaborator Author

I'd also add the opposite of this: cast array

type CastArray<X | X[]> = X[]

@fratzinger
Copy link

+1.
What about calling it Arrayable<T>? This would follow Promisable<T>.

Max10240 added a commit to Max10240/type-fest that referenced this issue Aug 11, 2024
Max10240 added a commit to Max10240/type-fest that referenced this issue Aug 11, 2024
Max10240 added a commit to Max10240/type-fest that referenced this issue Aug 11, 2024
Max10240 added a commit to Max10240/type-fest that referenced this issue Aug 11, 2024
Max10240 added a commit to Max10240/type-fest that referenced this issue Aug 11, 2024
sindresorhus added a commit that referenced this issue Aug 12, 2024
Co-authored-by: Sindre Sorhus <[email protected]>
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 a pull request may close this issue.

3 participants