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
Today I found myself in a situation where I had to remove the numbers at the end of each string of one union type.
This is because I have my color tokens defined as an union of grey1 | grey2 | greyNN | red1 | red2 | redNN and I wanted just the name part for a function that was going to compose them, something like this:
And I wanted to make sure that I only passed valid colors. But for that I need the list without the number at the end.
I was surprised of how easy was to encode this using type-fest:
What do you think about adding this utility to the library? It can easily be extended to do a maximum of N digits. To be honest, I don't think anyone will need anything more than 2 or 3 or else you are doing something probably wrong
Regards
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:
The only use case I think now is the one I had with color tokens (which I would say is a big one for FE people).
Maybe providing the type to remove from the tail could make it more general? Like if you want to remove a suffix, or a list of suffixes? But I don't know how more hard that may be.
Hello!
Today I found myself in a situation where I had to remove the numbers at the end of each string of one union type.
This is because I have my color tokens defined as an union of
grey1 | grey2 | greyNN | red1 | red2 | redNN
and I wanted just the name part for a function that was going to compose them, something like this:And I wanted to make sure that I only passed valid colors. But for that I need the list without the number at the end.
I was surprised of how easy was to encode this using type-fest:
What do you think about adding this utility to the library? It can easily be extended to do a maximum of N digits. To be honest, I don't think anyone will need anything more than 2 or 3 or else you are doing something probably wrong
Regards
Upvote & Fund
The text was updated successfully, but these errors were encountered: