mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
exclude nested functions and classes at containingThis check
This commit is contained in:
@@ -102,7 +102,9 @@ namespace ts.refactor.convertArrowFunctionOrFunctionExpression {
|
||||
return;
|
||||
}
|
||||
|
||||
forEachChild(child, checkThis);
|
||||
if (!isClassLike(child) && !isFunctionDeclaration(child) && !isFunctionExpression(child)) {
|
||||
forEachChild(child, checkThis);
|
||||
}
|
||||
});
|
||||
|
||||
return containsThis;
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const zoo = /*x*/f/*w*/unction () {
|
||||
//// class Animal {
|
||||
//// weight = 42
|
||||
//// askWeight() { return this.weight }
|
||||
//// }
|
||||
//// const Insect = class {
|
||||
//// weight = 42
|
||||
//// askWeight() { return this.weight }
|
||||
//// }
|
||||
//// function callTaxi() { this.no = "054 xxx xx xx" }
|
||||
//// const callPizzaDelivery = function() { this.phone = "064 yyy yy yy"}
|
||||
//// };
|
||||
|
||||
goTo.select("x", "w");
|
||||
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function");
|
||||
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function");
|
||||
verify.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function");
|
||||
+4
-2
@@ -1,7 +1,9 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const bar = 42;
|
||||
//// const foo = /*x*/f/*w*/unction() {return this.bar;};
|
||||
//// const foo = /*x*/f/*w*/unction() {
|
||||
//// this.bar = "F-Express";
|
||||
//// return this.bar;
|
||||
//// };
|
||||
|
||||
goTo.select("x", "w");
|
||||
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to named function");
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const zoo = /*x*/(/*w*/) => {
|
||||
//// class Animal {
|
||||
//// weight = 42
|
||||
//// askWeight() { return this.weight }
|
||||
//// }
|
||||
//// const Insect = class {
|
||||
//// weight = 42
|
||||
//// askWeight() { return this.weight }
|
||||
//// }
|
||||
//// function callTaxi() { this.no = "054 xxx xx xx" }
|
||||
//// const callPizzaDelivery = function() { this.phone = "064 yyy yy yy"}
|
||||
//// };
|
||||
|
||||
goTo.select("x", "w");
|
||||
verify.refactorAvailable("Convert arrow function or function expression", "Convert to named function");
|
||||
verify.refactorAvailable("Convert arrow function or function expression", "Convert to anonymous function");
|
||||
verify.not.refactorAvailable("Convert arrow function or function expression", "Convert to arrow function");
|
||||
Reference in New Issue
Block a user