Add LiteralList and JoinUnion types#1159
Add LiteralList and JoinUnion types#1159benzaria wants to merge 31 commits intosindresorhus:mainfrom
LiteralList and JoinUnion types#1159Conversation
**Added**: - `LiteralList` a validator to check if a Tuple have exactly one of each member in given Union, No duplicate, Extras, or Less elements. - `JoinUnion` join a union members with the given delimiter (default: ','). **Modified** - `Join` delimiter (default: ','). Like `Array.join` default behavior.
ur right this is a weird scenario to return strings as Errors, like they are not needed actually but they can add a visual reason why the type is erroring. we can remove them in case @sindresorhus refuses. and lets be honest making the type #904 as suggested is not wort the effort for 4/5 union members |
|
@sindresorhus Can u give a thought on returning the string Errors so we can go forward. |
|
I agree that returning Error is kinda weird, but since there is no other way to report errors to the users, I'm kinda willing to do it, because some weird Error is better than no indication of what's wrong. I assume this solution does not suffer from performance issues like the one proposed in #904? |
- Fix: Corrected behavior when handling infinite-length lists (no longer returns true). - Add: Added comprehensive tests and documentation for `LiteralList`. - Improve: Enhanced error message formatting for clearer diagnostics.
|
@som-sm @sindresorhus I improved the errors! I think they look good and match with ts errors look |
|
@som-sm PR is ready, can u review ! |
|
Please run everything through AI, as requested multiple times on other pull requests (please do it on all your pull requests). |
benzaria
left a comment
There was a problem hiding this comment.
@sindresorhus Fixed Capitalized words in Error phrases
|
@som-sm Approved ! |
|
Yeah, I'm aware. I'll get to this sometime this week. |
|
@som-sm, Hey 👋 just following up on this, you mentioned you’d review it next week, but I haven’t seen any updates yet. |
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
|
@som-sm Could you please take some time to review this PR when you get a chance, so we can move it forward? |





Closes #904
Added:
LiteralLista validator to check if a Tuple have exactly one of each member in given Union, No duplicate, Extras, or Less elements.JoinUnionjoin a union members with the given delimiter (default: ',').Example:
Errors example


