Search code examples
javascriptwebstorm

WebStorm: extract function directly with an arrow


I try to find a way to extract a function with WebStorm (Cmd + Alt + M) directly with a fat arrow. But I didn't find a way to do that.

With image:

The start:

return _.sum(b.populationCounts) - _.sum(a.populationCounts);

The extract method by WebStorm:

function getNumber() {
  return _.sum(b.populationCounts) - _.sum(a.populationCounts);
}

return getNumber();

What I would like:

const getNumber = () =>
  _.sum(b.populationCounts) - _.sum(a.populationCounts);

return getNumber();

Is it possible? Someone has already done this?

I know it's possible to convert a function into a variable holding an arrow function but I would like to do it directly by the automatic WebStorm extract.

Thanks for your answer,


Solution

  • there are no settings for that; please vote for WEB-26073 to be notified on any progress with this feature