Skip to content

Commit

Permalink
"Convert parameters to destructured object": enable for functions wit…
Browse files Browse the repository at this point in the history
…h just one parameter (#46945)

* "Convert parameters to destructured object": enable for functions with just one parameter

Fixes #41753

* Add test
  • Loading branch information
OliverJAsh authored Feb 3, 2022
1 parent 9b0f01a commit b7d0117
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* @internal */
namespace ts.refactor.convertParamsToDestructuredObject {
const refactorName = "Convert parameters to destructured object";
const minimumParameterLength = 2;
const minimumParameterLength = 1;
const refactorDescription = getLocaleSpecificMessage(Diagnostics.Convert_parameters_to_destructured_object);

const toDestructuredAction = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// <reference path='fourslash.ts' />

////const foo = /*a*/(a: number)/*b*/ => { };
////foo(1);

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `const foo = ({ a }: { a: number; }) => { };
foo({ a: 1 });`,
});

0 comments on commit b7d0117

Please sign in to comment.