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
Allowed tuples to have both named and anonymous members #53356
base: main
Are you sure you want to change the base?
Allowed tuples to have both named and anonymous members #53356
Conversation
2dda8ac
to
b7816ea
Compare
| @@ -6399,7 +6399,7 @@ export interface TupleType extends GenericType { | |||
| hasRestElement: boolean; | |||
| combinedFlags: ElementFlags; | |||
| readonly: boolean; | |||
| labeledElementDeclarations?: readonly (NamedTupleMember | ParameterDeclaration)[]; | |||
| labeledElementDeclarations?: readonly (NamedTupleMember | ParameterDeclaration | undefined)[]; | |||
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.
[Breaking API Change] Is this the right choice to make? One alternative could be to rename it to elementDeclarations with a type like readonly (ParameterDeclaration | TypeNode). My hunch is that that would be preferable, but I'm going with this smaller change for now to make reviewing easier.
Co-authored-by: Jake Bailey <jabaile@microsoft.com>
Co-authored-by: Jake Bailey <jabaile@microsoft.com>
|
I think that it would be nice to get some code coverage for generic mapped types with array constraints. With them named and anonymous elements should be preserved in the same way. Similarly, it should be possible to add new named/anonymous elements using generic conditional types. |
Fixes #52853
Previously, the
labeledElementDeclarationsproperty onTupleTypes was all-or-nothing for having named vs. anonymous members. Now that it's possible for them to mix-and-match, this PR pulls logic fromgetParameterNameAtPositionintogetTupleElementLabelfor filling in a name (`${restParameterName}_${index}`).