Fix bug: FunctionDeclaration may have missing name (#20618)
This commit is contained in:
Родитель
f2f17454af
Коммит
b629ff4204
|
@ -658,11 +658,10 @@ namespace ts.refactor.extractSymbol {
|
|||
case SyntaxKind.Constructor:
|
||||
return "constructor";
|
||||
case SyntaxKind.FunctionExpression:
|
||||
return scope.name
|
||||
? `function expression '${scope.name.text}'`
|
||||
: "anonymous function expression";
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
return `function '${scope.name.text}'`;
|
||||
return scope.name
|
||||
? `function '${scope.name.text}'`
|
||||
: "anonymous function";
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return "arrow function";
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////export default function() {
|
||||
//// /*start*/0/*end*/
|
||||
////}
|
||||
|
||||
goTo.select('start', 'end')
|
||||
edit.applyRefactor({
|
||||
refactorName: "Extract Symbol",
|
||||
actionName: "function_scope_0",
|
||||
actionDescription: "Extract to inner function in anonymous function",
|
||||
newContent:
|
||||
`export default function() {
|
||||
/*RENAME*/newFunction();
|
||||
|
||||
function newFunction() {
|
||||
0;
|
||||
}
|
||||
}`
|
||||
});
|
Загрузка…
Ссылка в новой задаче