mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-29 16:29:19 -05:00
fix(48541): forbid function extraction to arrow function with expression body (#48548)
This commit is contained in:
@@ -3529,9 +3529,10 @@ namespace FourSlash {
|
||||
};
|
||||
}
|
||||
|
||||
public verifyRefactorAvailable(negative: boolean, triggerReason: ts.RefactorTriggerReason, name: string, actionName?: string) {
|
||||
public verifyRefactorAvailable(negative: boolean, triggerReason: ts.RefactorTriggerReason, name: string, actionName?: string, actionDescription?: string) {
|
||||
let refactors = this.getApplicableRefactorsAtSelection(triggerReason);
|
||||
refactors = refactors.filter(r => r.name === name && (actionName === undefined || r.actions.some(a => a.name === actionName)));
|
||||
refactors = refactors.filter(r =>
|
||||
r.name === name && (actionName === undefined || r.actions.some(a => a.name === actionName)) && (actionDescription === undefined || r.actions.some(a => a.description === actionDescription)));
|
||||
const isAvailable = refactors.length > 0;
|
||||
|
||||
if (negative) {
|
||||
|
||||
@@ -215,8 +215,8 @@ namespace FourSlashInterface {
|
||||
this.state.verifyRefactorsAvailable(names);
|
||||
}
|
||||
|
||||
public refactorAvailable(name: string, actionName?: string) {
|
||||
this.state.verifyRefactorAvailable(this.negative, "implicit", name, actionName);
|
||||
public refactorAvailable(name: string, actionName?: string, actionDescription?: string) {
|
||||
this.state.verifyRefactorAvailable(this.negative, "implicit", name, actionName, actionDescription);
|
||||
}
|
||||
|
||||
public refactorAvailableForTriggerReason(triggerReason: ts.RefactorTriggerReason, name: string, actionName?: string) {
|
||||
|
||||
@@ -639,7 +639,8 @@ namespace ts.refactor.extractSymbol {
|
||||
}
|
||||
|
||||
function isScope(node: Node): node is Scope {
|
||||
return isFunctionLikeDeclaration(node) || isSourceFile(node) || isModuleBlock(node) || isClassLike(node);
|
||||
return isArrowFunction(node) ? isFunctionBody(node.body) :
|
||||
isFunctionLikeDeclaration(node) || isSourceFile(node) || isModuleBlock(node) || isClassLike(node);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user