mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-04 14:56:16 -05:00
Simplify test cases
This commit is contained in:
@@ -123,6 +123,9 @@ namespace ts.codefix {
|
||||
case SyntaxKind.Parameter:
|
||||
const oldFunction = parent.parent;
|
||||
if (isArrowFunction(oldFunction) && oldFunction.parameters.length === 1) {
|
||||
// Lambdas with exactly one parameter are special because, after removal, there
|
||||
// must be an empty parameter list (i.e. `()`) and this won't necessarily be the
|
||||
// case if the parameter is simply removed (e.g. in `x => 1`).
|
||||
const newFunction = updateArrowFunction(
|
||||
oldFunction,
|
||||
oldFunction.modifiers,
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
|
||||
// @noUnusedLocals: true
|
||||
// @noUnusedParameters: true
|
||||
//// function f1() {
|
||||
//// [|return /*~a*/(/*~b*/x/*~c*/:/*~d*/number/*~e*/)/*~f*/ => /*~g*/{/*~h*/}/*~i*/|]
|
||||
//// }
|
||||
////[|/*~a*/(/*~b*/x/*~c*/:/*~d*/number/*~e*/)/*~f*/ => /*~g*/{/*~h*/}/*~i*/|]
|
||||
|
||||
// In a perfect world, /*~f*/ and /*~h*/ would probably be retained.
|
||||
verify.codeFix({
|
||||
description: "Remove declaration for: 'x'",
|
||||
index: 0,
|
||||
newRangeContent: "return /*~a*/() => /*~g*/ { }/*~i*/",
|
||||
newRangeContent: "/*~a*/() => /*~g*/ { }/*~i*/",
|
||||
});
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
|
||||
// @noUnusedLocals: true
|
||||
// @noUnusedParameters: true
|
||||
//// function f1() {
|
||||
//// [|return /*~a*/x/*~b*/ /*~c*/=>/*~d*/ {/*~e*/}/*~f*/|]
|
||||
//// }
|
||||
////[|/*~a*/x/*~b*/ /*~c*/=>/*~d*/ {/*~e*/}/*~f*/|]
|
||||
|
||||
// In a perfect world, /*~c*/ and /*~e*/ would probably be retained.
|
||||
verify.codeFix({
|
||||
description: "Remove declaration for: 'x'",
|
||||
index: 0,
|
||||
newRangeContent: "return /*~a*/() => /*~d*/ { }/*~f*/",
|
||||
newRangeContent: "/*~a*/() => /*~d*/ { }/*~f*/",
|
||||
});
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
|
||||
// @noUnusedLocals: true
|
||||
// @noUnusedParameters: true
|
||||
//// function f1() {
|
||||
//// [|return /*~a*/(/*~b*/x/*~c*/,/*~d*/y/*~e*/)/*~f*/ => /*~g*/x/*~h*/|]
|
||||
//// }
|
||||
////[|/*~a*/(/*~b*/x/*~c*/,/*~d*/y/*~e*/)/*~f*/ => /*~g*/x/*~h*/|]
|
||||
|
||||
// In a perfect world, /*~c*/ would probably be retained, rather than /*~e*/.
|
||||
verify.codeFix({
|
||||
description: "Remove declaration for: 'y'",
|
||||
index: 0,
|
||||
newRangeContent: "return /*~a*/(/*~b*/x/*~e*/)/*~f*/ => /*~g*/x/*~h*/",
|
||||
newRangeContent: "/*~a*/(/*~b*/x/*~e*/)/*~f*/ => /*~g*/x/*~h*/",
|
||||
});
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
|
||||
// @noUnusedLocals: true
|
||||
// @noUnusedParameters: true
|
||||
//// function f1() {
|
||||
//// [|return /*~a*/(/*~b*/x/*~c*/,/*~d*/y/*~e*/)/*~f*/ => /*~g*/y/*~h*/|]
|
||||
//// }
|
||||
////[|/*~a*/(/*~b*/x/*~c*/,/*~d*/y/*~e*/)/*~f*/ => /*~g*/y/*~h*/|]
|
||||
|
||||
verify.codeFix({
|
||||
description: "Remove declaration for: 'x'",
|
||||
index: 0,
|
||||
newRangeContent: "return /*~a*/(/*~d*/y/*~e*/)/*~f*/ => /*~g*/y/*~h*/",
|
||||
newRangeContent: "/*~a*/(/*~d*/y/*~e*/)/*~f*/ => /*~g*/y/*~h*/",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user