Fix: IsTuple<Type> when Type is an array containing rest element#436
Merged
Beraliv merged 6 commits intots-essentials:masterfrom Jun 16, 2025
Merged
Conversation
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
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
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.