mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
add more testcases
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// function doSomething(a){}
|
||||
//// doSomething(/*x*/(/*y*/) => 1 + 1);
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert arrow function or function expression",
|
||||
actionName: "Convert to anonymous function",
|
||||
actionDescription: "Convert to anonymous function",
|
||||
newContent: `function doSomething(a){}
|
||||
doSomething(function() {
|
||||
return 1 + 1;
|
||||
});`,
|
||||
});
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// [9,8,7].map(/*x*/n/*y*/ => n + 418);
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert arrow function or function expression",
|
||||
actionName: "Convert to anonymous function",
|
||||
actionDescription: "Convert to anonymous function",
|
||||
newContent: `[9,8,7].map(function(n) {
|
||||
return n + 418;
|
||||
});`,
|
||||
});
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const foo = /*x*/(/*y*/): number => a + 1;
|
||||
//// const increment = /*x*/(/*y*/a: number): number => a + 1;
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert arrow function or function expression",
|
||||
actionName: "Convert to anonymous function",
|
||||
actionDescription: "Convert to anonymous function",
|
||||
newContent: `const foo = function(): number {
|
||||
newContent: `const increment = function(a: number): number {
|
||||
return a + 1;
|
||||
};`,
|
||||
});
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// function foo(lambda){}
|
||||
//// foo(function /*x*/is/*y*/Even(n) {
|
||||
//// return n % 2 === 0;
|
||||
//// });
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert arrow function or function expression",
|
||||
actionName: "Convert to arrow function",
|
||||
actionDescription: "Convert to arrow function",
|
||||
newContent: `function foo(lambda){}
|
||||
foo((n) => n % 2 === 0);`,
|
||||
});
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const foo = /*x*/f/*y*/unction(): string {
|
||||
//// return "foobar";
|
||||
//// };
|
||||
//// [4,5,6,7].map(function /*x*/is/*y*/Even(n) {
|
||||
//// return n % 2 === 0;
|
||||
//// });
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert arrow function or function expression",
|
||||
actionName: "Convert to arrow function",
|
||||
actionDescription: "Convert to arrow function",
|
||||
newContent: `const foo = (): string => "foobar";`,
|
||||
newContent: `[4,5,6,7].map((n) => n % 2 === 0);`,
|
||||
});
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const concat = /*x*/f/*y*/unction(a: string, b: string): string {
|
||||
//// return a + b;
|
||||
//// };
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert arrow function or function expression",
|
||||
actionName: "Convert to arrow function",
|
||||
actionDescription: "Convert to arrow function",
|
||||
newContent: `const concat = (a: string, b: string): string => a + b;`,
|
||||
});
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// let isFoo = /*x*/(/*y*/n: number): boolean => n === 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: `function isFoo(n: number): boolean {
|
||||
return n === 42;
|
||||
}`,
|
||||
});
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// let foo = /*x*/(/*y*/): number => 42;
|
||||
//// /*x*/let/*y*/ foo = a => 1 + a;
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert arrow function or function expression",
|
||||
actionName: "Convert to named function",
|
||||
actionDescription: "Convert to named function",
|
||||
newContent: `function foo(): number {
|
||||
return 42;
|
||||
newContent: `function foo(a) {
|
||||
return 1 + a;
|
||||
}`,
|
||||
});
|
||||
Reference in New Issue
Block a user