Is there a refactoring to do this kind of conversion? (I'm using VSCode).
CodePudding user response:
Yes, there is a refactoring available in Visual Studio Code to convert method or constructor parameters to a property bag. Here's how you can do it:
Select the parameters that you want to convert to a property bag.
Press
Shift Alt F
to open the refactor menu.Select the "Convert parameters to destructured object" option from the menu.
Type the name of the property bag in the prompt that appears.
Press
Enter
to apply the refactoring.
After the refactoring, the parameters will be replaced with a destructured object containing the properties from the original parameters.