-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
"Convert parameters to destructured object": enable for functions with just one parameter #41753
Comments
I can see from the code that this would be a very easy change: we just need to tweak this constant:
I can go ahead and do that but I guess I need approval from the TS team beforehand. Is there any reason why we wouldn't want to do this? One potential downside is the refactoring will appear more frequently than it currently does, which might annoy some users. |
Thanks for pushing this forward @OliverJAsh. Really looking forward to this landing at some point! 🙏 |
…h just one parameter Fixes microsoft#41753
@RyanCavanaugh I would like to raise a PR to fix this, can you accept this issue and add it to the backlog? |
The React scenario makes a lot of sense; sure |
…h just one parameter Fixes microsoft#41753
…h just one parameter Fixes microsoft#41753
Thanks, PR here: #46945 |
Search Terms
Suggestion
Back when this refactor was added in #30089, it was decided that the refactor would not be available for functions with less than 2 parameters.
#30089 (comment)
I would like to suggest that this refactor should be available for functions with just one parameter.
Use Cases
The reason is because I often use this refactoring to make a function into a React component (which always receive their parameters aka props as an object), and it's not infrequent that I need to do this for a function that receives just one parameter.
Furthermore, it would be useful to run this refactoring if you plan to add more parameters immediately afterwards—as opposed to adding more parameters and then converting to an object.
Examples
should convert to
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: