"Convert parameters to destructured object": enable for functions with just one parameter (#46945)

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

Fixes https://github.com/microsoft/TypeScript/issues/41753

* Add test
This commit is contained in:
Oliver Joseph Ash
2022-02-03 18:13:05 +00:00
committed by GitHub
parent 9b0f01a13f
commit b7d011777e
2 changed files with 14 additions and 1 deletions

View File

@@ -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 = {

View File

@@ -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 });`,
});