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
Add the ability to merge tuple types while preserving the named properties of their elements.
π Motivating Example
Currently, when tuple types with named properties are merged using the spread operator ..., TypeScript loses the named properties of the tuple elements. This makes it difficult to maintain named parameter hints in function signatures when using rest parameters with merged tuple types.
π» Use Cases
Consider the following example:
typeSimpleArgs=[a: number,b: string];typeMergedArgs=[...SimpleArgs,c: boolean];functionexampleFunction(...args: MergedArgs){const[a,b,c]=args;// Do stuff with a,b,c}exampleFunction(1,'hello',true);
In this scenario, the named properties a, b, and c are lost when the tuple types are merged into MergedArgs. As a result, the parameter hints for exampleFunction do not show the named properties when mousing over the function signature.
It would be beneficial to have a way to merge tuple types that preserves the named properties of their elements, improving the developer experience when working with rest parameters in function signatures.
The text was updated successfully, but these errors were encountered:
Currently, when calling the blah function, the editor hints display the args rest parameter, but they do not display the named parameter hints from the tuple type (e.g., a: someType, b: anotherType, etc.).
BribeFromTheHive
changed the title
Improve Editor Hints for Rest Parameters with Tuple Types by Displaying Named Parameter Hints
Preserve Named Properties when Merging Tuple Types
Apr 20, 2023
I'd like to apologize that my initial feature request was a bit unclear. After seeing your reply, I realized that what I was trying to achieve was a bit more nuanced than I initially explained. So, I've gone ahead and updated the request with a clearer description/title and some practical use cases.
Suggestion
π Search Terms
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
Add the ability to merge tuple types while preserving the named properties of their elements.
π Motivating Example
Currently, when tuple types with named properties are merged using the spread operator
...
, TypeScript loses the named properties of the tuple elements. This makes it difficult to maintain named parameter hints in function signatures when using rest parameters with merged tuple types.π» Use Cases
Consider the following example:
In this scenario, the named properties a, b, and c are lost when the tuple types are merged into MergedArgs. As a result, the parameter hints for exampleFunction do not show the named properties when mousing over the function signature.
It would be beneficial to have a way to merge tuple types that preserves the named properties of their elements, improving the developer experience when working with rest parameters in function signatures.
The text was updated successfully, but these errors were encountered: