You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Refactorings to convert from function declarations to function expressions #44080
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):
"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.
Activity
RyanCavanaugh commentedon May 13, 2021
Curious, why would you want to?
OliverJAsh commentedon May 13, 2021
We use function expressions instead of declarations for numerous reasons: https://gist.github.com/OliverJAsh/71cfca924b4cd144b57a764d7fb1cdff
Extract to function creates a declaration so I have to convert it (related: #31860).