New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ArrayExceptLastElement type #872
Comments
You can use import type { ArraySlice } from 'type-fest'
type A = ArraySlice<[0, 1, 2, 3, 4], 0, -1>;
// => [0, 1, 2, 3] |
Oh I didnt realize you could use a negative index that way. Thanks ! |
Reopening this, although it might be better as an actual bug report. Meaning I was able to use |
Can you provide a minimum reproduction? |
|
Oh, I feel dumb. ArraySlice works as intended, sorry for the mistake. |
Maybe there's a simpler way to do this, but here's a function that will get the inverse of LastArrayElement:
I had use for it in a string manipulation function where I used it to remove the last
.${string}
part in pathnames. Is it worth it for me to write a pull request for this ?The text was updated successfully, but these errors were encountered: