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
"Convert parameters to destructured object": enable for functions with just one parameter #41753
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.
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.
Activity
OliverJAsh commentedon May 20, 2021
I can see from the code that this would be a very easy change: we just need to tweak this constant:
TypeScript/src/services/refactors/convertParamsToDestructuredObject.ts
Line 4 in 87c5b6a
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.
schickling commentedon Jun 3, 2021
Thanks for pushing this forward Oliver Joseph Ash (@OliverJAsh). Really looking forward to this landing at some point! 🙏
"Convert parameters to destructured object": enable for functions wit…
OliverJAsh commentedon Nov 29, 2021
Ryan Cavanaugh (@RyanCavanaugh) I would like to raise a PR to fix this, can you accept this issue and add it to the backlog?
RyanCavanaugh commentedon Nov 29, 2021
The React scenario makes a lot of sense; sure
"Convert parameters to destructured object": enable for functions wit…
"Convert parameters to destructured object": enable for functions wit…
OliverJAsh commentedon Nov 29, 2021
Thanks, PR here: #46945
"Convert parameters to destructured object": enable for functions wit…