TypeScript/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_shorthandProperty.ts
Gabriela Araujo Britto 84087d0e0a
Use shorthand property assignment in convert parameters to object (#30468)
* create shorthand property assignment in argument object when possible

* add shorthand property assignment test

* don't offer refactor on jsdoc comment

* add jsdoc test

* improve jsdoc test

* use crlf
2019-03-19 09:28:09 -07:00

25 lines
795 B
TypeScript

/// <reference path='fourslash.ts' />
// @Filename: f.ts
////function /*a*/f/*b*/(a: number, b: number, ...rest: string[]) { }
////const a = 4;
////const b = 5;
////f(a, b);
////const rest = ["a", "b", "c"];
////f(a, b, ...rest);
////f(/** a */ a /** aa */, /** b */ b /** bb */);
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: `function f({ a, b, rest = [] }: { a: number; b: number; rest?: string[]; }) { }
const a = 4;
const b = 5;
f({ a, b });
const rest = ["a", "b", "c"];
f({ a, b, rest: [...rest] });
f({ /** a */ a /** aa */, /** b */ b /** bb */ });`
});