Suggestion
🔍 Search Terms
refactoring quick fix vs code action
✅ Viability Checklist
My suggestion meets these guidelines:
⭐ Suggestion
We already have refactorings to convert function expressions (arrow or non-arrow) to a function declaration, e.g. we can use "convert to named function" on both of these:
const fn1 = function () {
return 1;
};
const fn2 = () => {
return 1;
};
However, there is no refactoring to convert in the opposite direction—from a function declaration to a function expression.
I would like to suggest adding these refactorings so we cover all possibilities.
Note we do already have these refactorings (#28250):
- "Convert to arrow function"
- "Convert to anonymous function"
However these only work on function expressions—they don't work on function declarations. Perhaps we could fix this by extending the scope of those refactorings so they do work on function declarations.
Suggestion
🔍 Search Terms
refactoring quick fix vs code action
✅ Viability Checklist
My suggestion meets these guidelines:
⭐ Suggestion
We already have refactorings to convert function expressions (arrow or non-arrow) to a function declaration, e.g. we can use "convert to named function" on both of these:
However, there is no refactoring to convert in the opposite direction—from a function declaration to a function expression.
I would like to suggest adding these refactorings so we cover all possibilities.
Note we do already have these refactorings (#28250):
However these only work on function expressions—they don't work on function declarations. Perhaps we could fix this by extending the scope of those refactorings so they do work on function declarations.