Intelij: how to change the syntax of extracted function in typescript?

Viewed 114

When extracting a method in InteliJ typescript:

const main = () => {
  console.log(`say hello`);
};

The extracted method uses the following function syntax:

function extracted() {
  console.log(`say hello`);
}

const main = () => {
  extracted();
};

Is there a way to change the syntax that intelij uses to be

const extracted = () => {
  console.log(`say hello`);
}

const main = () => {
  extracted();
};

1 Answers

It is now available in IntelliJ IDEA/WebStorm at the moment. Feel free to follow WEB-26073.

However, you can press Option(Alt)+Enter on the extracted function and select Convert to variable holding arrow function after Extract Method refactoring.

enter image description here

Related