mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-06 06:49:29 -05:00
Fix missing func modifier (#40379)
* Fix missing function modifier * Update src/services/refactors/convertArrowFunctionOrFunctionExpression.ts Co-authored-by: Ron Buckton <ron.buckton@microsoft.com> Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
This commit is contained in:
@@ -208,7 +208,10 @@ namespace ts.refactor.convertArrowFunctionOrFunctionExpression {
|
||||
|
||||
const { variableDeclaration, variableDeclarationList, statement, name } = variableInfo;
|
||||
suppressLeadingTrivia(statement);
|
||||
const newNode = factory.createFunctionDeclaration(func.decorators, statement.modifiers, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body);
|
||||
|
||||
const modifiersFlags = (getCombinedModifierFlags(variableDeclaration) & ModifierFlags.Export) | getEffectiveModifierFlags(func);
|
||||
const modifiers = factory.createModifiersFromModifierFlags(modifiersFlags);
|
||||
const newNode = factory.createFunctionDeclaration(func.decorators, length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body);
|
||||
|
||||
if (variableDeclarationList.declarations.length === 1) {
|
||||
return textChanges.ChangeTracker.with(context, t => t.replaceNode(file, statement, newNode));
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const /*x*/a/*y*/ = async () => { return 42; };
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert arrow function or function expression",
|
||||
actionName: "Convert to named function",
|
||||
actionDescription: "Convert to named function",
|
||||
newContent: `async function a() { return 42; }`,
|
||||
});
|
||||
Reference in New Issue
Block a user