Replace more 'verify.rangeAfterCodeFix' with 'verify.codeFix' (#18800)

This commit is contained in:
Andy
2017-10-10 11:28:05 -07:00
committed by GitHub
parent b839e17e17
commit 927ffefcf4
95 changed files with 545 additions and 224 deletions

View File

@@ -3661,7 +3661,7 @@
"category": "Message",
"code": 90013
},
"Change {0} to {1}.": {
"Change '{0}' to '{1}'.": {
"category": "Message",
"code": 90014
},

View File

@@ -2381,7 +2381,7 @@ Actual: ${stringify(fullActual)}`);
}));
return ts.flatMap(ts.deduplicate(diagnosticsForCodeFix, ts.equalOwnProperties), diagnostic => {
if (errorCode && errorCode !== diagnostic.code) {
if (errorCode !== undefined && errorCode !== diagnostic.code) {
return;
}

View File

@@ -3,4 +3,7 @@
//// interface I {}
//// [|/* */ class /* */ C /* */ extends /* */ I|]{}
verify.rangeAfterCodeFix("/* */ class /* */ C /* */ implements /* */ I");
verify.codeFix({
description: "Change 'extends' to 'implements'.",
newRangeContent: "/* */ class /* */ C /* */ implements /* */ I",
});

View File

@@ -5,4 +5,8 @@
//// [|abstract class A extends I1 implements I2|] { }
verify.rangeAfterCodeFix("abstract class A implements I1, I2");
verify.codeFix({
description: "Change 'extends' to 'implements'.",
// TODO: GH#18794
newRangeContent: "abstract class A implements I1 , I2",
});

View File

@@ -3,4 +3,7 @@
////interface I<X> { x: X}
////[|class C<T extends string , U> extends I<T>|]{}
verify.rangeAfterCodeFix("class C<T extends string , U> implements I<T>");
verify.codeFix({
description: "Change 'extends' to 'implements'.",
newRangeContent: "class C<T extends string , U> implements I<T>",
});

View File

@@ -10,4 +10,8 @@
//// @sealed
//// [|class A extends I1 implements I2 { }|]
verify.rangeAfterCodeFix("class A implements I1, I2 { }");
verify.codeFix({
description: "Change 'extends' to 'implements'.",
// TODO: GH#18794
newRangeContent: "class A implements I1 , I2 { }",
});

View File

@@ -1,4 +1,7 @@
/// <reference path='fourslash.ts' />
//// var x: [|?|] = 12;
verify.rangeAfterCodeFix("any");
verify.codeFix({
description: "Change '?' to 'any'.",
newRangeContent: "any",
});

View File

@@ -2,4 +2,10 @@
/// <reference path='fourslash.ts' />
//// function f(x: [|number?|]) {
//// }
verify.rangeAfterCodeFix("number | null", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0);
verify.codeFix({
description: "Change 'number?' to 'number | null'.",
errorCode: 8020,
index: 0,
newRangeContent: "number | null",
});

View File

@@ -2,4 +2,10 @@
/// <reference path='fourslash.ts' />
//// var f = function f(x: [|string?|]) {
//// }
verify.rangeAfterCodeFix("string | null | undefined", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 1);
verify.codeFix({
description: "Change 'string?' to 'string | null | undefined'.",
errorCode: 8020,
index: 1,
newRangeContent: "string | null | undefined",
});

View File

@@ -3,4 +3,10 @@
////class C {
//// p: [|*|]
////}
verify.rangeAfterCodeFix("any", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0);
verify.codeFix({
description: "Change '*' to 'any'.",
errorCode: 8020,
index: 0,
newRangeContent: "any",
});

View File

@@ -3,4 +3,10 @@
////class C {
//// p: [|*|] = 12
////}
verify.rangeAfterCodeFix("any", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0);
verify.codeFix({
description: "Change '*' to 'any'.",
errorCode: 8020,
index: 0,
newRangeContent: "any",
});

View File

@@ -2,4 +2,9 @@
/// <reference path='fourslash.ts' />
//// var x = 12 as [|number?|];
verify.rangeAfterCodeFix("number | null", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0);
verify.codeFix({
description: "Change 'number?' to 'number | null'.",
errorCode: 8020,
index: 0,
newRangeContent: "number | null",
});

View File

@@ -2,4 +2,9 @@
//// var f = <[|function(number?): number|]>(x => x);
// note: without --strict, number? --> number, not number | null
verify.rangeAfterCodeFix("(arg0: number) => number", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0);
verify.codeFix({
description: "Change 'function(number?): number' to '(arg0: number) => number'.",
errorCode: 8020,
index: 0,
newRangeContent: "(arg0: number) => number",
});

View File

@@ -1,4 +1,7 @@
/// <reference path='fourslash.ts' />
//// var f: { [K in keyof number]: [|*|] };
verify.rangeAfterCodeFix("any");
verify.codeFix({
description: "Change '*' to 'any'.",
newRangeContent: "any",
});

View File

@@ -1,3 +1,7 @@
/// <reference path='fourslash.ts' />
//// declare function index(ix: number): [|*|];
verify.rangeAfterCodeFix("any");
verify.codeFix({
description: "Change '*' to 'any'.",
newRangeContent: "any",
});

View File

@@ -1,3 +1,7 @@
/// <reference path='fourslash.ts' />
//// var index: { (ix: number): [|?|] };
verify.rangeAfterCodeFix("any");
verify.codeFix({
description: "Change '?' to 'any'.",
newRangeContent: "any",
});

View File

@@ -1,3 +1,7 @@
/// <reference path='fourslash.ts' />
//// var index: { new (ix: number): [|?|] };
verify.rangeAfterCodeFix("any");
verify.codeFix({
description: "Change '?' to 'any'.",
newRangeContent: "any",
});

View File

@@ -1,4 +1,7 @@
/// <reference path='fourslash.ts' />
//// var x: [|*|] = 12;
verify.rangeAfterCodeFix("any");
verify.codeFix({
description: "Change '*' to 'any'.",
newRangeContent: "any",
});

View File

@@ -1,3 +1,7 @@
/// <reference path='fourslash.ts' />
//// var index = { get p(): [|*|] { return 12 } };
verify.rangeAfterCodeFix("any");
verify.codeFix({
description: "Change '*' to 'any'.",
newRangeContent: "any",
});

View File

@@ -1,3 +1,7 @@
/// <reference path='fourslash.ts' />
//// var index = { set p(x: [|*|]) { } };
verify.rangeAfterCodeFix("any");
verify.codeFix({
description: "Change '*' to 'any'.",
newRangeContent: "any",
});

View File

@@ -1,3 +1,7 @@
/// <reference path='fourslash.ts' />
//// var index: { [s: string]: [|*|] };
verify.rangeAfterCodeFix("any");
verify.codeFix({
description: "Change '*' to 'any'.",
newRangeContent: "any",
});

View File

@@ -3,4 +3,8 @@
//// m(): [|*|] {
//// }
////}
verify.rangeAfterCodeFix("any");
verify.codeFix({
description: "Change '*' to 'any'.",
newRangeContent: "any",
});

View File

@@ -2,4 +2,8 @@
////declare class C {
//// m(): [|*|];
////}
verify.rangeAfterCodeFix("any");
verify.codeFix({
description: "Change '*' to 'any'.",
newRangeContent: "any",
});

View File

@@ -2,4 +2,8 @@
////declare class C {
//// p: [|*|];
////}
verify.rangeAfterCodeFix("any");
verify.codeFix({
description: "Change '*' to 'any'.",
newRangeContent: "any",
});

View File

@@ -2,4 +2,8 @@
////class C {
//// p: [|*|] = 12;
////}
verify.rangeAfterCodeFix("any");
verify.codeFix({
description: "Change '*' to 'any'.",
newRangeContent: "any",
});

View File

@@ -1,4 +1,10 @@
// @strict: true
/// <reference path='fourslash.ts' />
////type T = [|...number?|];
verify.rangeAfterCodeFix("number[] | null", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0);
verify.codeFix({
description: "Change '...number?' to 'number[] | null'.",
errorCode: 8020,
index: 0,
newRangeContent: "number[] | null",
});

View File

@@ -1,4 +1,7 @@
/// <reference path='fourslash.ts' />
//// var x: [|......number[][]|] = 12;
verify.rangeAfterCodeFix("number[][][][]");
verify.codeFix({
description: "Change '......number[][]' to 'number[][][][]'.",
newRangeContent: "number[][][][]",
});

View File

@@ -1,4 +1,7 @@
/// <reference path='fourslash.ts' />
//// var x: [|Array.<number>|] = 12;
verify.rangeAfterCodeFix("number[]");
verify.codeFix({
description: "Change 'Array.<number>' to 'number[]'.",
newRangeContent: "number[]",
});

View File

@@ -2,4 +2,9 @@
/// <reference path='fourslash.ts' />
//// var x: [|?number|] = 12;
verify.rangeAfterCodeFix("number | null", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0);
verify.codeFix({
description: "Change '?number' to 'number | null'.",
errorCode: 8020,
index: 0,
newRangeContent: "number | null",
});

View File

@@ -2,4 +2,8 @@
/// <reference path='fourslash.ts' />
//// var x: [|number?|] = 12;
verify.rangeAfterCodeFix("number | null | undefined", /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, 1);
verify.codeFix({
description: "Change 'number?' to 'number | null | undefined'.",
index: 1,
newRangeContent: "number | null | undefined",
});

View File

@@ -1,4 +1,7 @@
/// <reference path='fourslash.ts' />
//// var x: [|!number|] = 12;
verify.rangeAfterCodeFix("number");
verify.codeFix({
description: "Change '!number' to 'number'.",
newRangeContent: "number",
});

View File

@@ -1,4 +1,7 @@
/// <reference path='fourslash.ts' />
//// var x: [|function(this: number, number): string|] = 12;
verify.rangeAfterCodeFix("(this: number, arg1: number) => string");
verify.codeFix({
description: "Change 'function(this: number, number): string' to '(this: number, arg1: number) => string'.",
newRangeContent: "(this: number, arg1: number) => string",
});

View File

@@ -1,4 +1,7 @@
/// <reference path='fourslash.ts' />
//// var x: [|function(new: number)|] = 12;
verify.rangeAfterCodeFix("new () => number");
verify.codeFix({
description: "Change 'function(new: number)' to 'new () => number'.",
newRangeContent: "new () => number",
});

View File

@@ -1,13 +1,16 @@
/// <reference path='fourslash.ts' />
//// class A {
//// f() {}
//// }
////class A {
//// f() {}
////}
////
//// let B = class implements A {[| |]}
////let B = class implements A {[| |]}
verify.rangeAfterCodeFix(`
f(): void{
throw new Error("Method not implemented.");
}
`);
verify.codeFix({
description: "Implement interface 'A'.",
// TODO: GH#18795
newRangeContent: `f(): void {\r
throw new Error("Method not implemented.");\r
}\r
`
});

View File

@@ -1,14 +1,17 @@
/// <reference path='fourslash.ts' />
//// function foo<T>(a: T) {
//// abstract class C<U> {
//// abstract a: T | U;
//// }
//// return C;
//// }
////function foo<T>(a: T) {
//// abstract class C<U> {
//// abstract a: T | U;
//// }
//// return C;
////}
////
//// let B = class extends foo("s")<number> {[| |]}
////let B = class extends foo("s")<number> {[| |]}
verify.rangeAfterCodeFix(`
a: string | number;
`);
verify.codeFix({
description: "Implement inherited abstract class.",
// TODO: GH#18795
newRangeContent: `a: string | number;\r
`
});

View File

@@ -1,14 +1,17 @@
/// <reference path='fourslash.ts' />
//// function foo<T>(a: T) {
//// abstract class C<U> {
//// abstract a: T | U;
//// }
//// return C;
//// }
////function foo<T>(a: T) {
//// abstract class C<U> {
//// abstract a: T | U;
//// }
//// return C;
////}
////
//// class B extends foo("s")<number> {[| |]}
////class B extends foo("s")<number> {[| |]}
verify.rangeAfterCodeFix(`
a: string | number;
`);
verify.codeFix({
description: "Implement inherited abstract class.",
// TODO: GH#18795
newRangeContent: `a: string | number;\r
`
});

View File

@@ -1,31 +1,34 @@
/// <reference path='fourslash.ts' />
//// abstract class A {
//// private _a: string;
////abstract class A {
//// private _a: string;
////
//// abstract get a(): number | string;
//// abstract get b(): this;
//// abstract get c(): A;
//// abstract get a(): number | string;
//// abstract get b(): this;
//// abstract get c(): A;
////
//// abstract set d(arg: number | string);
//// abstract set e(arg: this);
//// abstract set f(arg: A);
//// abstract set d(arg: number | string);
//// abstract set e(arg: this);
//// abstract set f(arg: A);
////
//// abstract get g(): string;
//// abstract set g(newName: string);
//// }
////
//// // Don't need to add anything in this case.
//// abstract class B extends A {}
////
//// class C extends A {[| |]}
//// abstract get g(): string;
//// abstract set g(newName: string);
////}
////
////// Don't need to add anything in this case.
////abstract class B extends A {}
////
////class C extends A {[| |]}
verify.rangeAfterCodeFix(`
a: string | number;
b: this;
c: A;
d: string | number;
e: this;
f: A;
g: string;
`);
verify.codeFix({
description: "Implement inherited abstract class.",
// TODO: GH#18795
newRangeContent: `a: string | number;\r
b: this;\r
c: A;\r
d: string | number;\r
e: this;\r
f: A;\r
g: string;\r
`
});

View File

@@ -1,24 +1,27 @@
/// <reference path='fourslash.ts' />
//// abstract class A {
////abstract class A {
//// abstract f(a: number, b: string): boolean;
//// abstract f(a: number, b: string): this;
//// abstract f(a: string, b: number): Function;
//// abstract f(a: string): Function;
//// abstract foo(): number;
//// }
////}
////
//// class C extends A {[| |]}
////class C extends A {[| |]}
verify.rangeAfterCodeFix(`
f(a: number, b: string): boolean;
f(a: number, b: string): this;
f(a: string, b: number): Function;
f(a: string): Function;
f(a: any, b?: any) {
throw new Error("Method not implemented.");
}
foo(): number {
throw new Error("Method not implemented.");
}
`);
verify.codeFix({
description: "Implement inherited abstract class.",
// TODO: GH#18795
newRangeContent: `f(a: number, b: string): boolean;\r
f(a: number, b: string): this;\r
f(a: string, b: number): Function;\r
f(a: string): Function;\r
f(a: any, b?: any) {\r
throw new Error("Method not implemented.");\r
}\r
foo(): number {\r
throw new Error("Method not implemented.");\r
}\r
`
});

View File

@@ -1,13 +1,16 @@
/// <reference path='fourslash.ts' />
//// abstract class A {
////abstract class A {
//// abstract f(): this;
//// }
////}
////
//// class C extends A {[| |]}
////class C extends A {[| |]}
verify.rangeAfterCodeFix(`
f(): this {
throw new Error("Method not implemented.");
}
`);
verify.codeFix({
description: "Implement inherited abstract class.",
// TODO: GH#18795
newRangeContent: `f(): this {\r
throw new Error("Method not implemented.");\r
}\r
`
});

View File

@@ -1,12 +1,16 @@
/// <reference path='fourslash.ts' />
//// abstract class A<T> {
////abstract class A<T> {
//// abstract f(x: T): T;
//// }
////}
////
//// class C extends A<number> {[| |]}
////class C extends A<number> {[| |]}
verify.rangeAfterCodeFix(`f(x: number): number{
throw new Error("Method not implemented.");
}
`);
verify.codeFix({
description: "Implement inherited abstract class.",
// TODO: GH#18795
newRangeContent: `f(x: number): number {\r
throw new Error("Method not implemented.");\r
}\r
`
});

View File

@@ -1,12 +1,16 @@
/// <reference path='fourslash.ts' />
//// abstract class A<T> {
////abstract class A<T> {
//// abstract f(x: T): T;
//// }
////}
////
//// class C<U> extends A<U> {[| |]}
////class C<U> extends A<U> {[| |]}
verify.rangeAfterCodeFix(`f(x: U): U{
throw new Error("Method not implemented.");
}
`);
verify.codeFix({
description: "Implement inherited abstract class.",
// TODO: GH#18795
newRangeContent: `f(x: U): U {\r
throw new Error("Method not implemented.");\r
}\r
`
});

View File

@@ -1,15 +1,18 @@
/// <reference path='fourslash.ts' />
//// abstract class A {
////abstract class A {
//// abstract x: number;
//// abstract y: this;
//// abstract z: A;
//// }
////}
////
//// class C extends A {[| |]}
////class C extends A {[| |]}
verify.rangeAfterCodeFix(`
x: number;
y: this;
z: A;
`);
verify.codeFix({
description: "Implement inherited abstract class.",
// TODO: GH#18795
newRangeContent: `x: number;\r
y: this;\r
z: A;\r
`
});

View File

@@ -1,11 +1,12 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////[| class greeter {
////class greeter {
//// private function1() {
//// }
////} |]
////}
verify.rangeAfterCodeFix(`
class greeter {
}`);
verify.codeFix({
description: `Remove declaration for: 'function1'.`,
newFileContent: "class greeter {\n}",
});

View File

@@ -1,15 +1,17 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [| class greeter {
////class greeter {
//// public function2() {
//// }
//// private function1() {
//// }
////} |]
////}
verify.rangeAfterCodeFix(`
class greeter {
verify.codeFix({
description: `Remove declaration for: 'function1'.`,
newFileContent: `class greeter {
public function2() {
}
}`);
}`,
});

View File

@@ -1,11 +1,12 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////[|class greeter {
////class greeter {
//// private function1 = function() {
//// }
////} |]
////}
verify.rangeAfterCodeFix(`
class greeter {
}`);
verify.codeFix({
description: `Remove declaration for: 'function1'.`,
newFileContent: "class greeter {\n}",
});

View File

@@ -8,5 +8,9 @@
//// } |]
////}
verify.rangeAfterCodeFix(`public function2(){
}`);
verify.codeFix({
description: `Remove declaration for: 'function1'.`,
newRangeContent: `public function2(){
}
`,
});

View File

@@ -1,8 +1,11 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [|class C {
//// private ["string"] (){}
//// }|]
////class C {
//// private ["string"] (){}
////}
verify.rangeAfterCodeFix("class C { }");
verify.codeFix({
description: `Remove declaration for: '"string"'.`,
newFileContent: "class C {\n}",
});

View File

@@ -1,8 +1,11 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [|class C {
//// private "string" (){}
//// }|]
////class C {
//// private "string" (){}
////}
verify.rangeAfterCodeFix("class C { }");
verify.codeFix({
description: `Remove declaration for: '"string"'.`,
newFileContent: "class C {\n}",
});

View File

@@ -1,13 +1,13 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [|namespace A {
////namespace A {
//// namespace B {
//// }
//// }|]
verify.rangeAfterCodeFix(`
namespace A {
}
`);
//// }
////}
verify.codeFix({
description: "Remove declaration for: 'B'.",
newFileContent: `namespace A {
}`,
});

View File

@@ -5,4 +5,8 @@
//// [|constructor(private p1: string, public p2: boolean, public p3: any, p5)|] { p5; }
//// }
verify.rangeAfterCodeFix("constructor(public p2: boolean, public p3: any, p5)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
verify.codeFix({
description: "Remove declaration for: 'p1'.",
index: 0,
newRangeContent: "constructor(public p2: boolean, public p3: any, p5)",
});

View File

@@ -5,4 +5,8 @@
//// [|constructor(private p1: string, public p2: boolean, public p3: any, p5) |] { p5; }
//// }
verify.rangeAfterCodeFix("constructor(private _p1: string, public p2: boolean, public p3: any, p5)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1);
verify.codeFix({
description: "Prefix 'p1' with an underscore.",
index: 1,
newRangeContent: "constructor(private _p1: string, public p2: boolean, public p3: any, p5)",
});

View File

@@ -5,4 +5,8 @@
//// [|constructor(public p1: string, private p2: boolean, public p3: any, p5)|] { p5; }
//// }
verify.rangeAfterCodeFix("constructor(public p1: string, public p3: any, p5)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
verify.codeFix({
description: "Remove declaration for: 'p2'.",
index: 0,
newRangeContent: "constructor(public p1: string, public p3: any, p5)",
});

View File

@@ -5,4 +5,8 @@
//// [|constructor(public p1: string, public p2: boolean, private p3: any, p5)|] { p5; }
//// }
verify.rangeAfterCodeFix("constructor(public p1: string, public p2: boolean, p5)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
verify.codeFix({
description: "Remove declaration for: 'p3'.",
index: 0,
newRangeContent: "constructor(public p1: string, public p2: boolean, p5)",
});

View File

@@ -5,4 +5,8 @@
//// [|constructor(private readonly p2: boolean, p5)|] { p5; }
//// }
verify.rangeAfterCodeFix("constructor(p5)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
verify.codeFix({
description: "Remove declaration for: 'p2'.",
index: 0,
newRangeContent: "constructor(p5)",
});

View File

@@ -4,4 +4,8 @@
////function [|greeter( x)|] {
////}
verify.rangeAfterCodeFix("greeter()", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
verify.codeFix({
description: "Remove declaration for: 'x'.",
index: 0,
newRangeContent: "greeter()",
});

View File

@@ -4,4 +4,8 @@
////function [|greeter( x) |] {
////}
verify.rangeAfterCodeFix("greeter( _x)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1);
verify.codeFix({
description: "Prefix 'x' with an underscore.",
index: 1,
newRangeContent: "greeter( _x)",
});

View File

@@ -5,4 +5,8 @@
//// use(x);
////}
verify.rangeAfterCodeFix("greeter(x)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
verify.codeFix({
description: "Remove declaration for: 'y'.",
index: 0,
newRangeContent: "greeter(x)",
});

View File

@@ -5,4 +5,8 @@
//// y++;
////}
verify.rangeAfterCodeFix("greeter(y)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
verify.codeFix({
description: "Remove declaration for: 'x'.",
index: 0,
newRangeContent: "greeter(y)",
});

View File

@@ -5,4 +5,8 @@
//// use(x, z);
////}
verify.rangeAfterCodeFix("function greeter(x,z)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
verify.codeFix({
description: "Remove declaration for: 'y'.",
index: 0,
newRangeContent: "function greeter(x,z) ",
});

View File

@@ -6,4 +6,8 @@
//// [|return (x:number) => {}|]
//// }
verify.rangeAfterCodeFix("return () => {}", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
verify.codeFix({
description: "Remove declaration for: 'x'.",
index: 0,
newRangeContent: "return () => {}",
});

View File

@@ -6,4 +6,8 @@
//// [|return (x:number) => {} |]
//// }
verify.rangeAfterCodeFix("return (_x:number) => {}", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1);
verify.codeFix({
description: "Prefix 'x' with an underscore.",
index: 1,
newRangeContent: "return (_x:number) => {}",
});

View File

@@ -1,11 +1,14 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [| namespace greeter {
//// type hw = "Hello" |"world";
//// export type nw = "No" | "Way";
//// } |]
////namespace greeter {
//// type hw = "Hello" |"world";
//// export type nw = "No" | "Way";
////}
verify.rangeAfterCodeFix(`namespace greeter {
verify.codeFix({
description: "Remove declaration for: 'hw'.",
newFileContent: `namespace greeter {
export type nw = "No" | "Way";
}`);
}`,
});

View File

@@ -4,4 +4,7 @@
////[|class greeter<T> |] {
////}
verify.rangeAfterCodeFix("class greeter");
verify.codeFix({
description: "Remove declaration for: 'T'.",
newRangeContent: "class greeter ",
});

View File

@@ -5,4 +5,7 @@
//// public a: X;
////}
verify.rangeAfterCodeFix("class greeter<X>");
verify.codeFix({
description: "Remove declaration for: 'Y'.",
newRangeContent: "class greeter<X> ",
});

View File

@@ -6,4 +6,7 @@
//// public b: Z;
////}
verify.rangeAfterCodeFix("class greeter<X, Z>");
verify.codeFix({
description: "Remove declaration for: 'Y'.",
newRangeContent: "class greeter<X, Z> ",
});

View File

@@ -3,4 +3,7 @@
// @noUnusedLocals: true
//// [|function f1<T>() {}|]
verify.rangeAfterCodeFix("function f1() {}");
verify.codeFix({
description: "Remove declaration for: 'T'.",
newRangeContent: "function f1() {}",
});

View File

@@ -3,4 +3,7 @@
// @noUnusedLocals: true
//// [|function f1<X, Y>(a: X) {a}|]
verify.rangeAfterCodeFix("function f1<X>(a: X) {a}");
verify.codeFix({
description: "Remove declaration for: 'Y'.",
newRangeContent: "function f1<X>(a: X) {a}",
});

View File

@@ -3,4 +3,7 @@
// @noUnusedLocals: true
//// [|function f1<X, Y, Z>(a: X) {a;var b:Z;b}|]
verify.rangeAfterCodeFix("function f1<X, Z>(a: X) {a;var b:Z;b}");
verify.codeFix({
description: "Remove declaration for: 'Y'.",
newRangeContent: "function f1<X, Z>(a: X) {a;var b:Z;b}",
});

View File

@@ -4,4 +4,7 @@
// @noUnusedParameters: true
//// [|interface I<T> {}|]
verify.rangeAfterCodeFix("interface I {}");
verify.codeFix({
description: "Remove declaration for: 'T'.",
newRangeContent: "interface I {}",
});

View File

@@ -6,4 +6,7 @@
//// [|return <T>(x:number) => {x}|]
//// }
verify.rangeAfterCodeFix("return (x:number) => {x}");
verify.codeFix({
description: "Remove declaration for: 'T'.",
newRangeContent: "return(x:number) => {x}",
});

View File

@@ -6,4 +6,7 @@
//// [|new <T, U>(a: T): void;|]
//// }
verify.rangeAfterCodeFix("new <T>(a: T): void;");
verify.codeFix({
description: "Remove declaration for: 'U'.",
newRangeContent: "new <T>(a: T): void;",
});

View File

@@ -7,4 +7,7 @@
//// [|new <T, U, K>(a: T): A<U>;|]
//// }
verify.rangeAfterCodeFix("new <T, U>(a: T): A<U>;");
verify.codeFix({
description: "Remove declaration for: 'K'.",
newRangeContent: "new <T, U>(a: T): A<U>;",
});

View File

@@ -6,4 +6,7 @@
//// }
//// [|var y: new <T,U>(a:T)=>void;|]
verify.rangeAfterCodeFix("var y: new <T>(a:T)=>void;");
verify.codeFix({
description: "Remove declaration for: 'U'.",
newRangeContent: "var y: new <T>(a:T)=>void;",
});

View File

@@ -5,4 +5,7 @@
//// [|f1<T extends number>()|] {}
//// }
verify.rangeAfterCodeFix("f1()");
verify.codeFix({
description: "Remove declaration for: 'T'.",
newRangeContent: "f1()",
});

View File

@@ -5,4 +5,7 @@
//// [|f1<T extends number, U>(a: U)|] {a;}
//// }
verify.rangeAfterCodeFix("f1<U>(a: U)");
verify.codeFix({
description: "Remove declaration for: 'T'.",
newRangeContent: "f1<U>(a: U)",
});

View File

@@ -5,4 +5,7 @@
//// [|public f1<X, Y, Z>(a: X)|] { a; var b: Z; b }
//// }
verify.rangeAfterCodeFix("public f1<X, Z>(a: X)");
verify.codeFix({
description: "Remove declaration for: 'Y'.",
newRangeContent: "public f1<X, Z>(a: X)",
});

View File

@@ -1,15 +1,18 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// function f1 () {
////function f1 () {
//// [|let x = 10;
//// {
//// let x = 11;
//// }
//// x;|]
//// }
////}
verify.rangeAfterCodeFix(`let x = 10;
{
}
x;`);
verify.codeFix({
description: "Remove declaration for: 'x'.",
newRangeContent: `let x = 10;
{
}
x;`,
});

View File

@@ -5,4 +5,7 @@
//// [|private greeting: string;|]
////}
verify.rangeAfterCodeFix("");
verify.codeFix({
description: "Remove declaration for: 'greeting'.",
newRangeContent: "",
});

View File

@@ -6,4 +6,7 @@
//// private greeting: string;|]
////}
verify.rangeAfterCodeFix("public greeting1;");
verify.codeFix({
description: "Remove declaration for: 'greeting'.",
newRangeContent: "public greeting1;\n",
});

View File

@@ -5,4 +5,7 @@
//// private X = function() {};
////|]}
verify.rangeAfterCodeFix("");
verify.codeFix({
description: "Remove declaration for: 'X'.",
newRangeContent: "\n",
});

View File

@@ -7,5 +7,7 @@
//// }
//// }
verify.rangeAfterCodeFix("for(; ;)");
verify.codeFix({
description: "Remove declaration for: 'i'.",
newRangeContent: "for(; ;) ",
});

View File

@@ -7,4 +7,7 @@
//// }
//// }
verify.rangeAfterCodeFix("for(var i = 0; ;i++)");
verify.codeFix({
description: "Remove declaration for: 'j'.",
newRangeContent: "for(var i = 0; ;i++)",
});

View File

@@ -7,4 +7,7 @@
//// }
//// }
verify.rangeAfterCodeFix("for(var i = 0, k=0; ;i++,k++)");
verify.codeFix({
description: "Remove declaration for: 'j'.",
newRangeContent: "for(var i = 0, k=0; ;i++, k++)",
});

View File

@@ -7,4 +7,7 @@
//// }
//// }
verify.rangeAfterCodeFix("for(var j = 0, k=0; ;j++,k++)");
verify.codeFix({
description: "Remove declaration for: 'i'.",
newRangeContent: "for(var j= 0, k=0; ;j++, k++) ",
});

View File

@@ -7,4 +7,7 @@
//// }
//// }
verify.rangeAfterCodeFix(`for (const _elem in ["a", "b", "c"])`, /*includeWhiteSpace*/ true, /*errorCode*/ 0);
verify.codeFix({
description: "Prefix 'elem' with an underscore.",
newRangeContent: 'for (const _elem in ["a", "b", "c"])'
});

View File

@@ -7,5 +7,8 @@
//// }
//// }
verify.rangeAfterCodeFix("const {} of ", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
verify.codeFix({
description: "Remove declaration for: 'elem'.",
index: 0,
newRangeContent: "const {} of",
});

View File

@@ -7,5 +7,9 @@
//// }
//// }
verify.rangeAfterCodeFix("const _elem of", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1);
verify.codeFix({
description: "Prefix 'elem' with an underscore.",
index: 1,
newRangeContent: "const _elem of"
});

View File

@@ -9,8 +9,11 @@
////}|]
////
verify.rangeAfterCodeFix(`{
verify.codeFix({
description: "Remove declaration for: 'x'.",
newRangeContent: `{
for (const elem of ["a", "b", "c"]) {
elem;
}
}`, /*includeWhiteSpace*/ true);
}`
});

View File

@@ -6,4 +6,7 @@
//// [|var x: string;
//// export var y: string;|]
verify.rangeAfterCodeFix("export var y: string;");
verify.codeFix({
description: "Remove declaration for: 'x'.",
newRangeContent: "export var y: string;",
});

View File

@@ -7,4 +7,7 @@
//// z;
//// export var y: string;
verify.rangeAfterCodeFix("var z: number;");
verify.codeFix({
description: "Remove declaration for: 'x'.",
newRangeContent: "var z: number;",
});

View File

@@ -6,4 +6,7 @@
//// [|var x = function f1() {}
//// export var y: string;|]
verify.rangeAfterCodeFix("export var y: string;");
verify.codeFix({
description: "Remove declaration for: 'x'.",
newRangeContent: "export var y: string;",
});

View File

@@ -7,4 +7,8 @@
//// x;
//// export var y: string;
verify.rangeAfterCodeFix(`var x = function f1() {}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0);
verify.codeFix({
description: "Remove declaration for: 'm'.",
index: 0,
newRangeContent: `var x = function f1() {}`,
});

View File

@@ -5,4 +5,7 @@
//// [|let a = "dummy entry";|]
////}
verify.rangeAfterCodeFix("");
verify.codeFix({
description: "Remove declaration for: 'a'.",
newRangeContent: "",
});

View File

@@ -8,4 +8,7 @@
//// }
////}
verify.rangeAfterCodeFix(`let a = "dummy entry", c = 0;`);
verify.codeFix({
description: "Remove declaration for: 'b'.",
newRangeContent: 'let a = "dummy entry", c = 0;',
});

View File

@@ -8,4 +8,7 @@
//// }
////}
verify.rangeAfterCodeFix(`let a = "dummy entry", b;`);
verify.codeFix({
description: "Remove declaration for: 'c'.",
newRangeContent: 'let a = "dummy entry", b;',
});