microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.75k stars 12.46k forks source link

Refactoring support: Reorder parameters #662

Open DickvdBrink opened 10 years ago

DickvdBrink commented 10 years ago

I would really like something like reorder parameters as a refactoring option, like C# already has: http://msdn.microsoft.com/en-us/library/5ss5z206.aspx

edit: This might be a bit hard when the info comes from a .d.ts file, though.

wongchichong commented 7 years ago

Please reopen this issue, #13080 marked duplicated and closed and this one marked closed because linked to the duplicated item.

DickvdBrink commented 7 years ago

@wongchichong, this issue is still open ;)

kitsonk commented 7 years ago

You seem to be confusing the posting in this issues timeline of the other issue.

wongchichong commented 7 years ago

Yaya.... LOL..

bugs181 commented 5 years ago

Just came across this very need. Refactoring a method signature in a very large project where the amount of calls is in the 100's.

JakeTunaley commented 5 years ago

This refactoring would also be useful on function types.

type MyFunction = (foo: string, bar: number) => void;

function doSomething (fn: MyFunction): void {
    fn('foo', 4);
}

doSomething((foo, bar) => foo + (2*bar));

// A reordering refactor on MyFunction would change all this to:

type MyFunction = (bar: number, foo: string) => void;

function doSomething (fn: MyFunction): void {
    fn(4, 'foo');
}

doSomething((bar, foo) => foo + (2*bar));
tonyhallett commented 5 years ago

Especially useful with generic type parameters

danielegarciav commented 3 years ago

Is there any way I can vote for this issue? This would be a really convenient refactor feature.

rauschma commented 9 months ago

I miss this feature often: Reordering parameters (of functions, methods, constructors) manually is painful and error-prone. Alas, it’s an important part of improving APIs.