-
Notifications
You must be signed in to change notification settings - Fork 130
Fix: IsTuple<Type> when Type is an array containing rest element
#436
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
Merged
Beraliv
merged 6 commits into
ts-essentials:master
from
som-sm:fix/is-tuple-with-arrays-with-rest
Jun 16, 2025
Merged
Fix: IsTuple<Type> when Type is an array containing rest element
#436
Beraliv
merged 6 commits into
ts-essentials:master
from
som-sm:fix/is-tuple-with-arrays-with-rest
Jun 16, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8c47bba to
c6f6999
Compare
213bbb9 to
a51a618
Compare
a51a618 to
09179c1
Compare
som-sm
commented
Jun 13, 2025
som-sm
commented
Jun 13, 2025
090bf04 to
6192049
Compare
Collaborator
|
Hey @som-sm ! Thank you for raising the PR, I'll check it later today or on the weekend |
Beraliv
reviewed
Jun 16, 2025
Beraliv
approved these changes
Jun 16, 2025
Collaborator
Beraliv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @som-sm! Thank you for raising this PR
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Checklist
Overview
Currently,
IsTupledoesn’t recognise arrays with a rest element and optional elements as tuples, such as[number?, …string[]].This PR fixes that by updating the implementation of
IsTuple.However, the above fix causes the following test to fail in
DeepNullable(similar withDeepUndefinable):There are two problems here:
Incorrect behavior in
IsTuplefornever[]:Previously,
IsTuple<never[]>returnednever[], which is incorrect—it should returnnever. The updated implementation corrects this.Incorrect handling of
neverinDeepNullable:Once
IsTuple<never[]>correctly returnsnever,DeepNullable<never[]>starts returningnever[]instead ofnull[]. This happens becauseDeepNullable<never>currently returnsnever.The issue becomes more apparent when testing with a case that doesn't involve
IsTuple:To fix this, this PR makes
DeepNullable<never>returnnull.