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
{{ message }}
Repository navigation
Multiple rest arguments may be allowed if they occupy different tuple nexting levels.Β #57182
The rule is just here to inform you that the thing you think syntactically is happening might not be. It can be evaded if you try hard enough (more simply, through aliasing/instantiation).
Ryan Cavanaugh (@RyanCavanaugh) - Yes, I get that it is more of warning than an error. The point of this issue is that both f and g contain double rest elements, but only g gets the error warning.
Because it is actually just a warning and not really an error, I would agree that it is not a defect, in both cases. If that's what you mean, then I agree.
The rule is just here to inform you that the thing you think syntactically is happening might not be. It can be evaded if you try hard enough (more simply, through aliasing/instantiation).
Ryan Cavanaugh (@RyanCavanaugh) do you have examples of this? is there a way to spread an array between elements of a tuple?
in the example above, the last tuple in the resulting union allows for multiple Identifier or Nothing types, when it should only allow one. expressed with invalid syntax, something like: [Comment, ...Comment[], Identifier | Nothing, Comment, ...Comment[], StringLiteral].
Lex (@unicornware) - I had assumed that the internal representation was limited to the following:
From the left:
[ <union of types that could be in 0th place>, <union of types that could be in 1th place>, .... ]
and that eventually reaches the end of the tuple, or a final repeating element.
From the right: (Same as from from the left but starting at the end.)
If that representation were actually the case, then I wouldn't be surprised by multiple Identifier | Nothing, just because it couldn't know for sure at which index that Identifier | Nothing would appear. (Of course a different internal representation could allow "single instance" along with "unknown index", but that would count as a new feature).
Given that assumed representation we would get:
From the left: [...(Comment|Identifier|Nothing|StringLiteral)[]] Note: it is equivalent to an array
From the right: [StringLiteral, ...(Comment|Identifier|Nothing)[]]
Unified, left first: [...(Comment|Identifier|Nothing)[], StringLiteral]
However, the type shown by TypeScript user interface:
Activity
RyanCavanaugh commentedon Feb 1, 2024
The rule is just here to inform you that the thing you think syntactically is happening might not be. It can be evaded if you try hard enough (more simply, through aliasing/instantiation).
craigphicks commentedon Feb 2, 2024
Ryan Cavanaugh (@RyanCavanaugh) - Yes, I get that it is more of warning than an
error. The point of this issue is that bothfandgcontain double rest elements, but onlyggets theerrorwarning.Because it is actually just a warning and not really an
error, I would agree that it is not a defect, in both cases. If that's what you mean, then I agree.typescript-bot commentedon Feb 5, 2024
This issue has been marked as "Not a Defect" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
unicornware commentedon Mar 14, 2024
Ryan Cavanaugh (@RyanCavanaugh) do you have examples of this? is there a way to spread an array between elements of a tuple?
in the example above, the last tuple in the resulting union allows for multiple
IdentifierorNothingtypes, when it should only allow one. expressed with invalid syntax, something like:[Comment, ...Comment[], Identifier | Nothing, Comment, ...Comment[], StringLiteral].craigphicks commentedon Mar 15, 2024
Lex (@unicornware) - I had assumed that the internal representation was limited to the following:
and that eventually reaches the end of the tuple, or a final repeating element.
If that representation were actually the case, then I wouldn't be surprised by multiple
Identifier | Nothing, just because it couldn't know for sure at which index thatIdentifier | Nothingwould appear. (Of course a different internal representation could allow "single instance" along with "unknown index", but that would count as a new feature).Given that assumed representation we would get:
From the left:
[...(Comment|Identifier|Nothing|StringLiteral)[]]Note: it is equivalent to an arrayFrom the right:
[StringLiteral, ...(Comment|Identifier|Nothing)[]]Unified, left first:
[...(Comment|Identifier|Nothing)[], StringLiteral]However, the type shown by TypeScript user interface:
obviously don't follow that assumption.
Yet the behavior you observed does follow that assumption.
It seems that the type displayed via tsserver and the type effectively being used by the compiler (which you observed) diverge, at some point.
refactor: comment parents