Open Leandro-Albano opened 2 years ago
I would be happy to submit a PR for that if approved!
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)