You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It turns out, RequireAtLeastOne also works with arrays:
typeNonEmptyArray=RequireAtLeastOne<unknown[],0>;exportconstfull: NonEmptyArray=[2];exportconstempty: NonEmptyArray=[];// Type '[]' is not assignable to type 'NonEmptyArray'.// Property '0' is missing in type '[]' but required in type 'Required<Pick<unknown[], 0>>'.
It also works for functions:
exportfunctionatLeastOneArg(...numbers: RequireAtLeastOne<number[],0>): number[]{returnnumbers;}atLeastOneArg(0);atLeastOneArg();// Argument of type '[]' is not assignable to parameter of type 'RequireAtLeastOne<number[], 0>'.// Property '0' is missing in type '[]' but required in type 'Required<Pick<number[], 0>>'.ts(2345)
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.
The text was updated successfully, but these errors were encountered:
fregante
added a commit
to refined-github/refined-github
that referenced
this issue
Jul 8, 2022
I'm opening this issue for documentation/googlability, but it should also probably be added to https://github.com/sindresorhus/type-fest/blob/main/source/require-at-least-one.d.ts
It turns out,
RequireAtLeastOne
also works with arrays:It also works for functions:
Upvote & Fund
The text was updated successfully, but these errors were encountered: