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
Is your feature request related to a real problem or use-case?
Use-case. Where we need an non empty array to be provided.
Describe a solution including usage in code example
type NonEmptyArray<T> = [T, ...T[]];
const invalid: NonEmptyArray<string> = []; // Type '[]' is not assignable to type 'NonEmptyArray<string>'. Source has 0 element(s) but target requires 1. const valid: NonEmptyArray<string> = ['']; // no error
Who does this impact? Who is this for?
Typescript users that need to type check for non empty arrays.
Describe alternatives you've considered (optional)
The alternative is to document the method/func/prop to notify the consumers that it needs a non empty array.
Additional context (optional)
The text was updated successfully, but these errors were encountered:
Hey @Leandro-Albano , sorry for the late reply got some personal issues.
Yes, it looks great from my perspective, please feel free to open PR and let me know to review it. Thanks
Is your feature request related to a real problem or use-case?
Use-case. Where we need an non empty array to be provided.
Describe a solution including usage in code example
type NonEmptyArray<T> = [T, ...T[]];
const invalid: NonEmptyArray<string> = []; // Type '[]' is not assignable to type 'NonEmptyArray<string>'. Source has 0 element(s) but target requires 1.
const valid: NonEmptyArray<string> = ['']; // no error
Who does this impact? Who is this for?
Typescript users that need to type check for non empty arrays.
Describe alternatives you've considered (optional)
The alternative is to document the method/func/prop to notify the consumers that it needs a non empty array.
Additional context (optional)
The text was updated successfully, but these errors were encountered: