Skip to content
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

ArraySlice: wrong type for union of tuples #982

Closed
eranhirsch opened this issue Nov 15, 2024 · 0 comments · Fixed by #986
Closed

ArraySlice: wrong type for union of tuples #982

eranhirsch opened this issue Nov 15, 2024 · 0 comments · Fixed by #986
Labels
bug Something isn't working

Comments

@eranhirsch
Copy link
Contributor

eranhirsch commented Nov 15, 2024

Bug description

When Start is 0 and no End is provided the output should be identical to the input, but for a union of tuples this doesn't work when they are of different lengths:

type X = ArraySlice<['a'] | ['b', 'c'], 0>;
//   ^? type X = ['a' | 'b'];

This doesn't repro when Start is not provided or provided as never:

type X = ArraySlice<['a'] | ['b', 'c']>;
//   ^? type X = ['a'] | ['b', 'c'];

type Y = ArraySlice<['a'] | ['b', 'c'], never>;
//   ^? type Y = ['a'] | ['b', 'c'];

Repro

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBDAnmApnA3nAglKBDRAZQBtgBjNAXzgDMoIQ4AiJVAWhpQGcYmBuALAAoYazQANAIxwAvNlwES5FAB4A2gHI8GgLpwAPnE0AjDQBo4GsrosAGAHyChAemdx3APQD8w0cgkATLLy+ESkFOpaugZGGqYWVrqOwq7ucN6+QmJw4gDMwTihShGa2nqGJuaW1joWAHYoAG4oUMkubp4+It1AA

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.
Fund with Polar
@eranhirsch eranhirsch added the bug Something isn't working label Nov 15, 2024
eranhirsch added a commit to remeda/remeda that referenced this issue Nov 15, 2024
A problem in type-fest's ArraySlice causes the issue
(sindresorhus/type-fest#982) but could be
avoided in most cases by avoiding using ArraySlice when not needed.

This is a patch, and the problem would still exist when the optional
limit param is used, but for the vast majority of usages of this
utility, it should be enough to reduce the surface area of the issue,
giving time for the issue to be resolved on the type-fest side.

Closes: #921
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant