diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts
index f54804c0eb5..e58a189c923 100644
--- a/src/harness/fourslash.ts
+++ b/src/harness/fourslash.ts
@@ -2049,7 +2049,7 @@ namespace FourSlash {
this.raiseError("Errors expected.");
}
- if (diagnostics.length > 1 && errorCode !== undefined) {
+ if (diagnostics.length > 1 && errorCode === undefined) {
this.raiseError("When there's more than one error, you must specify the errror to fix.");
}
diff --git a/src/services/codefixes/fixes.ts b/src/services/codefixes/fixes.ts
index d64a99ca1b9..ae13a965838 100644
--- a/src/services/codefixes/fixes.ts
+++ b/src/services/codefixes/fixes.ts
@@ -1 +1,2 @@
///
+///
\ No newline at end of file
diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts
new file mode 100644
index 00000000000..9a69af04bfc
--- /dev/null
+++ b/src/services/codefixes/unusedIdentifierFixes.ts
@@ -0,0 +1,153 @@
+/* @internal */
+namespace ts.codefix {
+ registerCodeFix({
+ errorCodes: [
+ Diagnostics._0_is_declared_but_never_used.code,
+ Diagnostics.Property_0_is_declared_but_never_used.code
+ ],
+ getCodeActions: (context: CodeFixContext) => {
+ const sourceFile = context.sourceFile;
+ const start = context.span.start;
+ const token = getTokenAtPosition(sourceFile, start);
+
+ if (token.kind === ts.SyntaxKind.Identifier) {
+ if (token.parent.kind === ts.SyntaxKind.VariableDeclaration) {
+ if (token.parent.parent.parent.kind === SyntaxKind.ForStatement) {
+ const forStatement = token.parent.parent.parent;
+ const initializer = forStatement.initializer;
+ if (initializer.declarations.length === 1) {
+ return createCodeFix("", initializer.pos, initializer.end - initializer.pos);
+ }
+ else {
+ if (initializer.declarations[0] === token.parent) {
+ return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1);
+ }
+ else {
+ return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1);
+ }
+ }
+ }
+ else if (token.parent.parent.parent.kind === SyntaxKind.ForInStatement) {
+ const forInStatement = token.parent.parent.parent;
+ const initializer = forInStatement.initializer;
+ return createCodeFix("{}", initializer.declarations[0].pos, initializer.declarations[0].end - initializer.declarations[0].pos);
+ }
+ else if (token.parent.parent.parent.kind === SyntaxKind.ForOfStatement) {
+ const forOfStatement = token.parent.parent.parent;
+ const initializer = forOfStatement.initializer;
+ return createCodeFix("{}", initializer.declarations[0].pos, initializer.declarations[0].end - initializer.declarations[0].pos);
+ }
+ else if (token.parent.parent.kind === SyntaxKind.CatchClause) {
+ const catchClause = token.parent.parent;
+ const parameter = catchClause.variableDeclaration.getChildren()[0];
+ return createCodeFix("", parameter.pos, parameter.end - parameter.pos);
+ }
+ else {
+ const variableStatement = token.parent.parent.parent;
+ if (variableStatement.declarationList.declarations.length === 1) {
+ return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos);
+ }
+ else {
+ const declarations = variableStatement.declarationList.declarations;
+ if (declarations[0].name === token) {
+ return createCodeFix("", token.parent.pos + 1, token.parent.end - token.parent.pos);
+ }
+ else {
+ return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1);
+ }
+ }
+ }
+ }
+
+ if (token.parent.kind === SyntaxKind.FunctionDeclaration ||
+ token.parent.kind === SyntaxKind.ClassDeclaration ||
+ token.parent.kind === SyntaxKind.InterfaceDeclaration ||
+ token.parent.kind === SyntaxKind.MethodDeclaration ||
+ token.parent.kind === SyntaxKind.ModuleDeclaration ||
+ token.parent.kind === SyntaxKind.PropertyDeclaration ||
+ token.parent.kind === SyntaxKind.ArrowFunction) {
+ return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
+ }
+
+ if (token.parent.kind === SyntaxKind.TypeParameter) {
+ const typeParameters = (token.parent.parent).typeParameters;
+ if (typeParameters.length === 1) {
+ return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2);
+ }
+ else {
+ if (typeParameters[0] === token.parent) {
+ return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1);
+ }
+ else {
+ return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1);
+ }
+ }
+ }
+
+ if (token.parent.kind === ts.SyntaxKind.Parameter) {
+ const functionDeclaration = token.parent.parent;
+ if (functionDeclaration.parameters.length === 1) {
+ return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
+ }
+ else {
+ if (functionDeclaration.parameters[0] === token.parent) {
+ return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1);
+ }
+ else {
+ return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1);
+ }
+ }
+ }
+
+ if (token.parent.kind === SyntaxKind.ImportSpecifier) {
+ const namedImports = token.parent.parent;
+ const elements = namedImports.elements;
+ if (elements.length === 1) {
+ // Only 1 import and it is unused. So the entire line could be removed.
+ return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
+ }
+ else {
+ if (elements[0] === token.parent) {
+ return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1);
+ }
+ else {
+ return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1);
+ }
+ }
+ }
+
+ if (token.parent.parent.kind === SyntaxKind.ImportClause || token.parent.parent.kind === SyntaxKind.ImportDeclaration) {
+ return createCodeFix("{}", token.parent.pos, token.parent.end - token.parent.pos);
+ }
+
+ if (token.parent.kind === SyntaxKind.ImportEqualsDeclaration) {
+ return createCodeFix("{}", token.pos, token.end - token.pos);
+ }
+
+ if (token.parent.kind === SyntaxKind.EnumDeclaration) {
+ return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
+ }
+ }
+
+ if (token.kind === SyntaxKind.PrivateKeyword && token.parent.kind === SyntaxKind.PropertyDeclaration) {
+ return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
+ }
+
+ if (token.kind === SyntaxKind.AsteriskToken && token.parent.kind === SyntaxKind.NamespaceImport) {
+ return createCodeFix("{}", token.parent.pos, token.parent.end - token.parent.pos);
+ }
+
+ return undefined;
+
+ function createCodeFix(newText: string, start: number, length: number): CodeAction[] {
+ return [{
+ description: getLocaleSpecificMessage(Diagnostics.Remove_unused_identifiers),
+ changes: [{
+ fileName: sourceFile.fileName,
+ textChanges: [{ newText, span: { start, length } }]
+ }]
+ }];
+ }
+ }
+ });
+}
diff --git a/tests/cases/fourslash/unusedClassInNamespace1.ts b/tests/cases/fourslash/unusedClassInNamespace1.ts
new file mode 100644
index 00000000000..586202ab0c7
--- /dev/null
+++ b/tests/cases/fourslash/unusedClassInNamespace1.ts
@@ -0,0 +1,10 @@
+///
+
+// @noUnusedLocals: true
+//// [| namespace greeter {
+//// class class1 {
+//// }
+//// } |]
+
+verify.codeFixAtPosition(`namespace greeter {
+}`);
diff --git a/tests/cases/fourslash/unusedClassInNamespace2.ts b/tests/cases/fourslash/unusedClassInNamespace2.ts
new file mode 100644
index 00000000000..c182f4e3655
--- /dev/null
+++ b/tests/cases/fourslash/unusedClassInNamespace2.ts
@@ -0,0 +1,15 @@
+///
+
+// @noUnusedLocals: true
+//// [| namespace greeter {
+//// export class class2 {
+//// }
+//// class class1 {
+//// }
+//// } |]
+
+verify.codeFixAtPosition(`namespace greeter {
+ export class class2 {
+ }
+}`);
+
diff --git a/tests/cases/fourslash/unusedClassInNamespace3.ts b/tests/cases/fourslash/unusedClassInNamespace3.ts
new file mode 100644
index 00000000000..6102f744717
--- /dev/null
+++ b/tests/cases/fourslash/unusedClassInNamespace3.ts
@@ -0,0 +1,12 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters:true
+//// [| namespace Validation {
+//// class c1 {
+////
+//// }/*1*/
+//// } |]
+
+verify.codeFixAtPosition(`namespace Validation {
+}`);
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedClassInNamespace4.ts b/tests/cases/fourslash/unusedClassInNamespace4.ts
new file mode 100644
index 00000000000..79701a5e0e2
--- /dev/null
+++ b/tests/cases/fourslash/unusedClassInNamespace4.ts
@@ -0,0 +1,19 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters:true
+
+//// [| namespace Validation {
+//// class c1 {
+////
+//// }
+////
+//// export class c2 {
+////
+//// }
+//// } |]
+
+verify.codeFixAtPosition(`namespace Validation {
+ export class c2 {
+ }
+}`);
diff --git a/tests/cases/fourslash/unusedClassInNamespace5.ts b/tests/cases/fourslash/unusedClassInNamespace5.ts
new file mode 100644
index 00000000000..80d8fe857bd
--- /dev/null
+++ b/tests/cases/fourslash/unusedClassInNamespace5.ts
@@ -0,0 +1,26 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters:true
+
+//// [| namespace Validation {
+//// class c1 {
+////
+//// }
+////
+//// export class c2 {
+////
+//// }
+////
+//// class c3 extends c1 {
+////
+//// }
+////} |]
+
+verify.codeFixAtPosition(`namespace Validation {
+ class c1 {
+ }
+
+ export class c2 {
+ }
+}`);
diff --git a/tests/cases/fourslash/unusedClassInNamespace6.ts b/tests/cases/fourslash/unusedClassInNamespace6.ts
new file mode 100644
index 00000000000..5db5b1aefa6
--- /dev/null
+++ b/tests/cases/fourslash/unusedClassInNamespace6.ts
@@ -0,0 +1,27 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters:true
+//// [| namespace Validation {
+//// class c1 {
+////
+//// }
+////
+//// export class c2 {
+////
+//// }
+////
+//// class c3 {
+//// public x: c1;
+//// }
+////} |]
+
+verify.codeFixAtPosition(`namespace Validation {
+ class c1 {
+
+ }
+
+ export class c2 {
+
+ }
+}`);
diff --git a/tests/cases/fourslash/unusedConstantInFunction1.ts b/tests/cases/fourslash/unusedConstantInFunction1.ts
new file mode 100644
index 00000000000..df373257809
--- /dev/null
+++ b/tests/cases/fourslash/unusedConstantInFunction1.ts
@@ -0,0 +1,10 @@
+///
+
+// @noUnusedLocals: true
+//// [| function f1 () {
+//// const x: string = "x";
+//// } |]
+
+verify.codeFixAtPosition(`function f1 () {
+}`);
+
diff --git a/tests/cases/fourslash/unusedEnumInFunction1.ts b/tests/cases/fourslash/unusedEnumInFunction1.ts
new file mode 100644
index 00000000000..1d88f07ebf7
--- /dev/null
+++ b/tests/cases/fourslash/unusedEnumInFunction1.ts
@@ -0,0 +1,11 @@
+///
+
+// @noUnusedLocals: true
+//// [| function f1 () {
+//// enum Directions { Up, Down}
+//// } |]
+
+verify.codeFixAtPosition(`function f1 () {
+}
+`);
+
diff --git a/tests/cases/fourslash/unusedFunctionInNamespace1.ts b/tests/cases/fourslash/unusedFunctionInNamespace1.ts
new file mode 100644
index 00000000000..e0f6b2e18ac
--- /dev/null
+++ b/tests/cases/fourslash/unusedFunctionInNamespace1.ts
@@ -0,0 +1,10 @@
+///
+
+// @noUnusedLocals: true
+//// [| namespace greeter {
+//// function function1() {
+//// }/*1*/
+//// } |]
+
+verify.codeFixAtPosition(`namespace greeter {
+}`);
diff --git a/tests/cases/fourslash/unusedFunctionInNamespace2.ts b/tests/cases/fourslash/unusedFunctionInNamespace2.ts
new file mode 100644
index 00000000000..c823777048e
--- /dev/null
+++ b/tests/cases/fourslash/unusedFunctionInNamespace2.ts
@@ -0,0 +1,14 @@
+///
+
+// @noUnusedLocals: true
+//// [| namespace greeter {
+//// export function function2() {
+//// }
+//// function function1() {
+//// }
+////} |]
+
+verify.codeFixAtPosition(`namespace greeter {
+ export function function2() {
+ }
+}`);
diff --git a/tests/cases/fourslash/unusedFunctionInNamespace3.ts b/tests/cases/fourslash/unusedFunctionInNamespace3.ts
new file mode 100644
index 00000000000..144e9f325b4
--- /dev/null
+++ b/tests/cases/fourslash/unusedFunctionInNamespace3.ts
@@ -0,0 +1,12 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters:true
+
+//// [| namespace Validation {
+//// function function1() {
+//// }
+////} |]
+
+verify.codeFixAtPosition(`namespace Validation {
+}`);
diff --git a/tests/cases/fourslash/unusedFunctionInNamespace4.ts b/tests/cases/fourslash/unusedFunctionInNamespace4.ts
new file mode 100644
index 00000000000..5b5995da9c7
--- /dev/null
+++ b/tests/cases/fourslash/unusedFunctionInNamespace4.ts
@@ -0,0 +1,11 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters:true
+//// [| namespace Validation {
+//// var function1 = function() {
+//// }
+////} |]
+
+verify.codeFixAtPosition(`namespace Validation {
+}`);
diff --git a/tests/cases/fourslash/unusedFunctionInNamespace5.ts b/tests/cases/fourslash/unusedFunctionInNamespace5.ts
new file mode 100644
index 00000000000..fa1eed2364a
--- /dev/null
+++ b/tests/cases/fourslash/unusedFunctionInNamespace5.ts
@@ -0,0 +1,28 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters:true
+////namespace Validation {
+//// var function1 = function() {
+//// }
+////
+//// export function function2() {
+////
+//// }
+////
+//// [| function function3() {
+//// function1();
+//// }
+////
+//// function function4() {
+////
+//// }
+////
+//// exp ort let a = function3; |]
+////}
+
+verify.codeFixAtPosition(`function function3() {
+ function1();
+ }
+
+ export let a = function3;`, 6133);
diff --git a/tests/cases/fourslash/unusedImports10FS.ts b/tests/cases/fourslash/unusedImports10FS.ts
new file mode 100644
index 00000000000..2eb923c9b8f
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports10FS.ts
@@ -0,0 +1,16 @@
+///
+
+// @noUnusedLocals: true
+//// module A {
+//// export class Calculator {
+//// public handelChar() {
+//// }
+//// }
+//// }
+
+//// module B {
+//// [|import a = A;|]
+//// }
+
+verify.codeFixAtPosition(" import {} = A;");
+
diff --git a/tests/cases/fourslash/unusedImports1FS.ts b/tests/cases/fourslash/unusedImports1FS.ts
new file mode 100644
index 00000000000..c3ae198d876
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports1FS.ts
@@ -0,0 +1,12 @@
+///
+
+// @noUnusedLocals: true
+// @Filename: file2.ts
+//// [| import {/*0*/Calculator/*1*/} from "./file1" |]
+
+// @Filename: file1.ts
+//// export class Calculator {
+////
+//// }
+
+verify.codeFixAtPosition(`import {} from "./file1"`);
diff --git a/tests/cases/fourslash/unusedImports2FS.ts b/tests/cases/fourslash/unusedImports2FS.ts
new file mode 100644
index 00000000000..a7144d1eb49
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports2FS.ts
@@ -0,0 +1,20 @@
+///
+
+// @noUnusedLocals: true
+// @Filename: file2.ts
+//// [| import {Calculator} from "./file1"
+//// import {test} from "./file1" |]
+
+//// var x = new Calculator();
+//// x.handleChar();
+
+// @Filename: file1.ts
+//// export class Calculator {
+//// handleChar() {}
+//// }
+//// export function test() {
+////
+//// }
+
+verify.codeFixAtPosition(`import {Calculator} from "./file1"
+import {} from "./file1"`);
diff --git a/tests/cases/fourslash/unusedImports3FS.ts b/tests/cases/fourslash/unusedImports3FS.ts
new file mode 100644
index 00000000000..f030232dc1e
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports3FS.ts
@@ -0,0 +1,24 @@
+///
+
+// @noUnusedLocals: true
+// @Filename: file2.ts
+////[| import {/*0*/Calculator,/*1*/ test, test2} from "./file1" |]
+
+//// test();
+//// test2();
+
+// @Filename: file1.ts
+//// export class Calculator {
+//// handleChar() {}
+//// }
+
+//// export function test() {
+////
+//// }
+
+//// export function test2() {
+////
+//// }
+
+verify.codeFixAtPosition(`import {test, test2} from "./file1"`);
+
diff --git a/tests/cases/fourslash/unusedImports4FS.ts b/tests/cases/fourslash/unusedImports4FS.ts
new file mode 100644
index 00000000000..ab37928eb01
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports4FS.ts
@@ -0,0 +1,24 @@
+///
+
+// @noUnusedLocals: true
+// @Filename: file2.ts
+//// [| import {Calculator/*0*/, test/*1*/, test2} from "./file1" |]
+////
+//// var x = new Calculator();
+//// x.handleChar();
+//// test2();
+
+// @Filename: file1.ts
+//// export class Calculator {
+//// handleChar() {}
+//// }
+////
+//// export function test() {
+////
+//// }
+////
+//// export function test2() {
+////
+//// }
+
+verify.codeFixAtPosition(`import {Calculator, test2} from "./file1"`);
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedImports5FS.ts b/tests/cases/fourslash/unusedImports5FS.ts
new file mode 100644
index 00000000000..1d68f6ae643
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports5FS.ts
@@ -0,0 +1,24 @@
+///
+
+// @noUnusedLocals: true
+// @Filename: file2.ts
+//// [| import {Calculator, test, test2} from "./file1" |]
+////
+//// var x = new Calculator();
+//// x.handleChar();
+//// test();
+
+// @Filename: file1.ts
+//// export class Calculator {
+//// handleChar() {}
+//// }
+////
+//// export function test() {
+////
+//// }
+////
+//// export function test2() {
+////
+//// }
+
+verify.codeFixAtPosition(`import {Calculator, test} from "./file1"`);
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedImports6FS.ts b/tests/cases/fourslash/unusedImports6FS.ts
new file mode 100644
index 00000000000..c8e1af92313
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports6FS.ts
@@ -0,0 +1,20 @@
+///
+
+// @noUnusedLocals: true
+// @Filename: file2.ts
+//// [| import d from "./file1" |]
+
+// @Filename: file1.ts
+//// export class Calculator {
+//// handleChar() { }
+//// }
+
+//// export function test() {
+////
+//// }
+
+//// export default function test2() {
+////
+//// }
+
+verify.codeFixAtPosition(`import {} from "./file1"`);
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedImports7FS.ts b/tests/cases/fourslash/unusedImports7FS.ts
new file mode 100644
index 00000000000..6dc0886e8ff
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports7FS.ts
@@ -0,0 +1,20 @@
+///
+
+// @noUnusedLocals: true
+// @Filename: file2.ts
+//// [| import * as n from "./file1" |]
+
+// @Filename: file1.ts
+//// export class Calculator {
+//// handleChar() { }
+//// }
+////
+//// export function test() {
+////
+//// }
+////
+//// export default function test2() {
+////
+//// }
+
+verify.codeFixAtPosition(`import {} from "./file1"`);
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedImports8FS.ts b/tests/cases/fourslash/unusedImports8FS.ts
new file mode 100644
index 00000000000..02564e35989
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports8FS.ts
@@ -0,0 +1,24 @@
+///
+
+// @noUnusedLocals: true
+// @Filename: file2.ts
+//// [|import {Calculator as calc, test as t1, test2 as t2} from "./file1"|]
+////
+//// var x = new calc();
+//// x.handleChar();
+//// t1();
+
+// @Filename: file1.ts
+//// export class Calculator {
+//// handleChar() { }
+//// }
+
+//// export function test() {
+////
+//// }
+
+//// export function test2() {
+////
+//// }
+
+verify.codeFixAtPosition(`import {Calculator as calc, test as t1} from "./file1"`);
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedImports9FS.ts b/tests/cases/fourslash/unusedImports9FS.ts
new file mode 100644
index 00000000000..2ba30c95bb7
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports9FS.ts
@@ -0,0 +1,20 @@
+///
+
+// @noUnusedLocals: true
+// @Filename: file2.ts
+//// [|import c = require('./file1')|]
+
+// @Filename: file1.ts
+//// export class Calculator {
+//// handleChar() { }
+//// }
+////
+//// export function test() {
+////
+//// }
+////
+//// export function test2() {
+////
+//// }
+
+verify.codeFixAtPosition("import {} = require('./file1')");
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace1.ts b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts
new file mode 100644
index 00000000000..8d07a8c7912
--- /dev/null
+++ b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts
@@ -0,0 +1,11 @@
+///
+
+// @noUnusedLocals: true
+//// [| namespace greeter {
+//// interface interface1 {
+//// }
+////} |]
+
+verify.codeFixAtPosition(`
+namespace greeter {
+}`);
diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace2.ts b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts
new file mode 100644
index 00000000000..baa46c65a0c
--- /dev/null
+++ b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts
@@ -0,0 +1,12 @@
+///
+
+// @noUnusedLocals: true
+////namespace greeter {
+//// [| export interface interface2 {
+//// }
+//// interface interface1 {
+//// } |]
+////}
+
+verify.codeFixAtPosition(`export interface interface2 {
+}`);
diff --git a/tests/cases/fourslash/unusedLocalsInFunction1.ts b/tests/cases/fourslash/unusedLocalsInFunction1.ts
new file mode 100644
index 00000000000..2edd7c176e7
--- /dev/null
+++ b/tests/cases/fourslash/unusedLocalsInFunction1.ts
@@ -0,0 +1,10 @@
+///
+
+// @noUnusedLocals: true
+//// [| function greeter() {
+//// var x = 0;
+////} |]
+
+verify.codeFixAtPosition(`
+function greeter() {
+}`);
diff --git a/tests/cases/fourslash/unusedLocalsInFunction2.ts b/tests/cases/fourslash/unusedLocalsInFunction2.ts
new file mode 100644
index 00000000000..8f843623974
--- /dev/null
+++ b/tests/cases/fourslash/unusedLocalsInFunction2.ts
@@ -0,0 +1,9 @@
+///
+
+// @noUnusedLocals: true
+////function greeter() {
+//// [| var x, y = 0; |]
+//// x++;
+////}
+
+verify.codeFixAtPosition("var x;", 6133);
diff --git a/tests/cases/fourslash/unusedLocalsInFunction3.ts b/tests/cases/fourslash/unusedLocalsInFunction3.ts
new file mode 100644
index 00000000000..3fc92541390
--- /dev/null
+++ b/tests/cases/fourslash/unusedLocalsInFunction3.ts
@@ -0,0 +1,10 @@
+///
+
+// @noUnusedLocals: true
+////function greeter() {
+//// [| var x, y = 0,z = 1; |]
+//// x++;
+//// z++;
+////}
+
+verify.codeFixAtPosition("var x,z = 1;", 6133);
diff --git a/tests/cases/fourslash/unusedLocalsInFunction4.ts b/tests/cases/fourslash/unusedLocalsInFunction4.ts
new file mode 100644
index 00000000000..54d3223f236
--- /dev/null
+++ b/tests/cases/fourslash/unusedLocalsInFunction4.ts
@@ -0,0 +1,10 @@
+///
+
+// @noUnusedLocals: true
+////function greeter() {
+//// [| var x,y = 0,z = 1; |]
+//// y++;
+//// z++;
+////}
+
+verify.codeFixAtPosition("var y = 0,z = 1;");
diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts
new file mode 100644
index 00000000000..43b782ce266
--- /dev/null
+++ b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts
@@ -0,0 +1,12 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters: true
+////class greeter {
+//// public function1() {
+//// [| var /*0*/x,/*1*/ y = 10; |]
+//// y++;
+//// }
+////}
+
+verify.codeFixAtPosition("var y = 10;");
diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts
new file mode 100644
index 00000000000..322cfad3940
--- /dev/null
+++ b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts
@@ -0,0 +1,12 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters: true
+////class greeter {
+//// public function1() {
+//// [| var x, y; |]
+//// y = 1;
+//// }
+////}
+
+verify.codeFixAtPosition("var y;");
diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts
new file mode 100644
index 00000000000..412b599b780
--- /dev/null
+++ b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts
@@ -0,0 +1,12 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters:true
+////class greeter {
+//// [| constructor() {
+//// var unused = 20;
+//// } |]
+////}
+
+verify.codeFixAtPosition(`constructor() {
+}`);
diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts
new file mode 100644
index 00000000000..eff9b7c8d54
--- /dev/null
+++ b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts
@@ -0,0 +1,18 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters: true
+////class greeter {
+//// [|constructor() {
+//// var unused = 20;
+//// var used = "dummy";
+//// used = used + "second part";
+//// }|]
+////}
+
+verify.codeFixAtPosition(`
+ constructor() {
+ var used = "dummy";
+ used = used + "second part";
+ }
+`);
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedMethodInClass1.ts b/tests/cases/fourslash/unusedMethodInClass1.ts
new file mode 100644
index 00000000000..7795a4d1530
--- /dev/null
+++ b/tests/cases/fourslash/unusedMethodInClass1.ts
@@ -0,0 +1,11 @@
+///
+
+// @noUnusedLocals: true
+////[| class greeter {
+//// private function1() {
+//// }
+////} |]
+
+verify.codeFixAtPosition(`
+class greeter {
+}`);
diff --git a/tests/cases/fourslash/unusedMethodInClass2.ts b/tests/cases/fourslash/unusedMethodInClass2.ts
new file mode 100644
index 00000000000..24b6fe155ef
--- /dev/null
+++ b/tests/cases/fourslash/unusedMethodInClass2.ts
@@ -0,0 +1,15 @@
+///
+
+// @noUnusedLocals: true
+//// [| class greeter {
+//// public function2() {
+//// }
+//// private function1() {
+//// }
+////} |]
+
+verify.codeFixAtPosition(`
+class greeter {
+ public function2() {
+ }
+}`);
diff --git a/tests/cases/fourslash/unusedMethodInClass3.ts b/tests/cases/fourslash/unusedMethodInClass3.ts
new file mode 100644
index 00000000000..eab535fb5af
--- /dev/null
+++ b/tests/cases/fourslash/unusedMethodInClass3.ts
@@ -0,0 +1,11 @@
+///
+
+// @noUnusedLocals: true
+////[|class greeter {
+//// private function1 = function() {
+//// }
+////} |]
+
+verify.codeFixAtPosition(`
+class greeter {
+}`);
diff --git a/tests/cases/fourslash/unusedMethodInClass4.ts b/tests/cases/fourslash/unusedMethodInClass4.ts
new file mode 100644
index 00000000000..ee27ec331eb
--- /dev/null
+++ b/tests/cases/fourslash/unusedMethodInClass4.ts
@@ -0,0 +1,12 @@
+///
+
+// @noUnusedLocals: true
+////class greeter {
+//// [|public function2(){
+//// }
+//// private function1 = function() {
+//// } |]
+////}
+
+verify.codeFixAtPosition(`public function2(){
+}`);
diff --git a/tests/cases/fourslash/unusedNamespaceInNamespace.ts b/tests/cases/fourslash/unusedNamespaceInNamespace.ts
new file mode 100644
index 00000000000..41fe162ef15
--- /dev/null
+++ b/tests/cases/fourslash/unusedNamespaceInNamespace.ts
@@ -0,0 +1,13 @@
+///
+
+// @noUnusedLocals: true
+//// [|namespace A {
+//// namespace B {
+//// }
+//// }|]
+
+verify.codeFixAtPosition(`
+namespace A {
+}
+`);
+
diff --git a/tests/cases/fourslash/unusedParameterInConstructor1.ts b/tests/cases/fourslash/unusedParameterInConstructor1.ts
new file mode 100644
index 00000000000..f53c6d3e8bd
--- /dev/null
+++ b/tests/cases/fourslash/unusedParameterInConstructor1.ts
@@ -0,0 +1,8 @@
+///
+
+// @noUnusedLocals: true
+//// class C1 {
+//// [|constructor(private p1: string, public p2: boolean, public p3: any, p5)|] { p5; }
+//// }
+
+verify.codeFixAtPosition("constructor(public p2: boolean, public p3: any, p5)");
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedParameterInFunction1.ts b/tests/cases/fourslash/unusedParameterInFunction1.ts
new file mode 100644
index 00000000000..2243af9f5f5
--- /dev/null
+++ b/tests/cases/fourslash/unusedParameterInFunction1.ts
@@ -0,0 +1,7 @@
+///
+
+// @noUnusedParameters: true
+////function [|greeter( x)|] {
+////}
+
+verify.codeFixAtPosition("greeter()");
diff --git a/tests/cases/fourslash/unusedParameterInFunction2.ts b/tests/cases/fourslash/unusedParameterInFunction2.ts
new file mode 100644
index 00000000000..493eafc5722
--- /dev/null
+++ b/tests/cases/fourslash/unusedParameterInFunction2.ts
@@ -0,0 +1,8 @@
+///
+
+// @noUnusedParameters: true
+////function [|greeter(x,y)|] {
+//// x++;
+////}
+
+verify.codeFixAtPosition("greeter(x)");
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedParameterInFunction3.ts b/tests/cases/fourslash/unusedParameterInFunction3.ts
new file mode 100644
index 00000000000..6d79ba071b4
--- /dev/null
+++ b/tests/cases/fourslash/unusedParameterInFunction3.ts
@@ -0,0 +1,8 @@
+///
+
+// @noUnusedParameters: true
+////function [|greeter(x,y)|] {
+//// y++;
+////}
+
+verify.codeFixAtPosition("greeter(y)");
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedParameterInFunction4.ts b/tests/cases/fourslash/unusedParameterInFunction4.ts
new file mode 100644
index 00000000000..b536543fb6d
--- /dev/null
+++ b/tests/cases/fourslash/unusedParameterInFunction4.ts
@@ -0,0 +1,9 @@
+///
+
+// @noUnusedParameters: true
+////[|function greeter(x,y,z) |] {
+//// x++;
+//// z++;
+////}
+
+verify.codeFixAtPosition("function greeter(x,z)");
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedParameterInLambda1.ts b/tests/cases/fourslash/unusedParameterInLambda1.ts
new file mode 100644
index 00000000000..c462b742569
--- /dev/null
+++ b/tests/cases/fourslash/unusedParameterInLambda1.ts
@@ -0,0 +1,9 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters: true
+//// function f1() {
+//// [|return (x:number) => {}|]
+//// }
+
+verify.codeFixAtPosition("return () => {}");
diff --git a/tests/cases/fourslash/unusedTypeParametersInClass1.ts b/tests/cases/fourslash/unusedTypeParametersInClass1.ts
new file mode 100644
index 00000000000..ab654a5150e
--- /dev/null
+++ b/tests/cases/fourslash/unusedTypeParametersInClass1.ts
@@ -0,0 +1,7 @@
+///
+
+// @noUnusedLocals: true
+////[|class greeter |] {
+////}
+
+verify.codeFixAtPosition("class greeter");
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedTypeParametersInClass2.ts b/tests/cases/fourslash/unusedTypeParametersInClass2.ts
new file mode 100644
index 00000000000..8e860c10e04
--- /dev/null
+++ b/tests/cases/fourslash/unusedTypeParametersInClass2.ts
@@ -0,0 +1,8 @@
+///
+
+// @noUnusedLocals: true
+////[|class greeter |] {
+//// public a: X;
+////}
+
+verify.codeFixAtPosition("class greeter");
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedTypeParametersInClass3.ts b/tests/cases/fourslash/unusedTypeParametersInClass3.ts
new file mode 100644
index 00000000000..75ae98f53e0
--- /dev/null
+++ b/tests/cases/fourslash/unusedTypeParametersInClass3.ts
@@ -0,0 +1,9 @@
+///
+
+// @noUnusedLocals: true
+////[|class greeter |] {
+//// public a: X;
+//// public b: Z;
+////}
+
+verify.codeFixAtPosition("class greeter");
diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction1.ts b/tests/cases/fourslash/unusedTypeParametersInFunction1.ts
new file mode 100644
index 00000000000..7177ed41c84
--- /dev/null
+++ b/tests/cases/fourslash/unusedTypeParametersInFunction1.ts
@@ -0,0 +1,6 @@
+///
+
+// @noUnusedLocals: true
+//// [|function f1() {}|]
+
+verify.codeFixAtPosition("function f1() {}");
diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction2.ts b/tests/cases/fourslash/unusedTypeParametersInFunction2.ts
new file mode 100644
index 00000000000..344ae303c75
--- /dev/null
+++ b/tests/cases/fourslash/unusedTypeParametersInFunction2.ts
@@ -0,0 +1,6 @@
+///
+
+// @noUnusedLocals: true
+//// [|function f1(a: X) {a}|]
+
+verify.codeFixAtPosition("function f1(a: X) {a}");
diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction3.ts b/tests/cases/fourslash/unusedTypeParametersInFunction3.ts
new file mode 100644
index 00000000000..746b174db18
--- /dev/null
+++ b/tests/cases/fourslash/unusedTypeParametersInFunction3.ts
@@ -0,0 +1,6 @@
+///
+
+// @noUnusedLocals: true
+//// [|function f1(a: X) {a;var b:Z;b}|]
+
+verify.codeFixAtPosition("function f1(a: X) {a;var b:Z;b}");
diff --git a/tests/cases/fourslash/unusedTypeParametersInInterface1.ts b/tests/cases/fourslash/unusedTypeParametersInInterface1.ts
new file mode 100644
index 00000000000..70d8bc7800c
--- /dev/null
+++ b/tests/cases/fourslash/unusedTypeParametersInInterface1.ts
@@ -0,0 +1,7 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters: true
+//// [|interface I {}|]
+
+verify.codeFixAtPosition("interface I {}");
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda1.ts b/tests/cases/fourslash/unusedTypeParametersInLambda1.ts
new file mode 100644
index 00000000000..73d70672368
--- /dev/null
+++ b/tests/cases/fourslash/unusedTypeParametersInLambda1.ts
@@ -0,0 +1,9 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters: true
+//// function f1() {
+//// [|return (x:number) => {x}|]
+//// }
+
+verify.codeFixAtPosition("return (x:number) => {x}");
diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda2.ts b/tests/cases/fourslash/unusedTypeParametersInLambda2.ts
new file mode 100644
index 00000000000..77c802f5c44
--- /dev/null
+++ b/tests/cases/fourslash/unusedTypeParametersInLambda2.ts
@@ -0,0 +1,9 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters: true
+//// var x : {
+//// [|new (a: T): void;|]
+//// }
+
+verify.codeFixAtPosition("new (a: T): void;");
diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda3.ts b/tests/cases/fourslash/unusedTypeParametersInLambda3.ts
new file mode 100644
index 00000000000..0ecb0338be2
--- /dev/null
+++ b/tests/cases/fourslash/unusedTypeParametersInLambda3.ts
@@ -0,0 +1,10 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters: true
+//// class A { public x: Dummy }
+//// var x : {
+//// [|new (a: T): A;|]
+//// }
+
+verify.codeFixAtPosition("new (a: T): A;");
diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda4.ts b/tests/cases/fourslash/unusedTypeParametersInLambda4.ts
new file mode 100644
index 00000000000..5a226fc9005
--- /dev/null
+++ b/tests/cases/fourslash/unusedTypeParametersInLambda4.ts
@@ -0,0 +1,9 @@
+///
+
+// @noUnusedLocals: true
+//// class A {
+//// public x: T;
+//// }
+//// [|var y: new (a:T)=>void;|]
+
+verify.codeFixAtPosition("var y: new (a:T)=>void;");
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedTypeParametersInMethod1.ts b/tests/cases/fourslash/unusedTypeParametersInMethod1.ts
new file mode 100644
index 00000000000..7a9f04147d6
--- /dev/null
+++ b/tests/cases/fourslash/unusedTypeParametersInMethod1.ts
@@ -0,0 +1,8 @@
+///
+
+// @noUnusedLocals: true
+//// class C1 {
+//// [|f1()|] {}
+//// }
+
+verify.codeFixAtPosition("f1()");
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedTypeParametersInMethod2.ts b/tests/cases/fourslash/unusedTypeParametersInMethod2.ts
new file mode 100644
index 00000000000..3650cfbad98
--- /dev/null
+++ b/tests/cases/fourslash/unusedTypeParametersInMethod2.ts
@@ -0,0 +1,8 @@
+///
+
+// @noUnusedLocals: true
+//// class C1 {
+//// [|f1(a: U)|] {a;}
+//// }
+
+verify.codeFixAtPosition("f1(a: U)");
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedTypeParametersInMethods1.ts b/tests/cases/fourslash/unusedTypeParametersInMethods1.ts
new file mode 100644
index 00000000000..cb9b965ca4d
--- /dev/null
+++ b/tests/cases/fourslash/unusedTypeParametersInMethods1.ts
@@ -0,0 +1,8 @@
+///
+
+// @noUnusedLocals: true
+//// class A {
+//// [|public f1(a: X)|] { a; var b: Z; b }
+//// }
+
+verify.codeFixAtPosition("public f1(a: X)");
diff --git a/tests/cases/fourslash/unusedVariableInBlocks.ts b/tests/cases/fourslash/unusedVariableInBlocks.ts
new file mode 100644
index 00000000000..e9dedaef31e
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInBlocks.ts
@@ -0,0 +1,15 @@
+///
+
+// @noUnusedLocals: true
+//// function f1 () {
+//// [|let x = 10;
+//// {
+//// let x = 11;
+//// }
+//// x;|]
+//// }
+
+verify.codeFixAtPosition(`let x = 10;
+ {
+ }
+ x;`);
diff --git a/tests/cases/fourslash/unusedVariableInClass1.ts b/tests/cases/fourslash/unusedVariableInClass1.ts
new file mode 100644
index 00000000000..82bb99016ef
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInClass1.ts
@@ -0,0 +1,8 @@
+///
+
+// @noUnusedLocals: true
+////class greeter {
+//// [|private greeting: string;|]
+////}
+
+verify.codeFixAtPosition("");
diff --git a/tests/cases/fourslash/unusedVariableInClass2.ts b/tests/cases/fourslash/unusedVariableInClass2.ts
new file mode 100644
index 00000000000..c971092584a
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInClass2.ts
@@ -0,0 +1,9 @@
+///
+
+// @noUnusedLocals: true
+////class greeter {
+//// [|public greeting1;
+//// private greeting: string;|]
+////}
+
+verify.codeFixAtPosition("public greeting1;");
diff --git a/tests/cases/fourslash/unusedVariableInClass3.ts b/tests/cases/fourslash/unusedVariableInClass3.ts
new file mode 100644
index 00000000000..8d2a62e7175
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInClass3.ts
@@ -0,0 +1,8 @@
+///
+
+// @noUnusedLocals: true
+////class greeter {[|
+//// private X = function() {};
+////|]}
+
+verify.codeFixAtPosition("");
diff --git a/tests/cases/fourslash/unusedVariableInForLoop1FS.ts b/tests/cases/fourslash/unusedVariableInForLoop1FS.ts
new file mode 100644
index 00000000000..0ee02ab4363
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInForLoop1FS.ts
@@ -0,0 +1,11 @@
+///
+
+// @noUnusedLocals: true
+//// function f1 () {
+//// [|for(var i = 0; ;) |]{
+////
+//// }
+//// }
+
+verify.codeFixAtPosition("for(; ;)");
+
diff --git a/tests/cases/fourslash/unusedVariableInForLoop2FS.ts b/tests/cases/fourslash/unusedVariableInForLoop2FS.ts
new file mode 100644
index 00000000000..1b1a0798c04
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInForLoop2FS.ts
@@ -0,0 +1,10 @@
+///
+
+// @noUnusedLocals: true
+//// function f1 () {
+//// [|for(var i = 0, j= 0; ;i++)|] {
+////
+//// }
+//// }
+
+verify.codeFixAtPosition("for(var i = 0; ;i++)");
diff --git a/tests/cases/fourslash/unusedVariableInForLoop3FS.ts b/tests/cases/fourslash/unusedVariableInForLoop3FS.ts
new file mode 100644
index 00000000000..4eed9599b15
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInForLoop3FS.ts
@@ -0,0 +1,10 @@
+///
+
+// @noUnusedLocals: true
+//// function f1 () {
+//// [|for(var i = 0, j= 0, k=0; ;i++, k++)|] {
+////
+//// }
+//// }
+
+verify.codeFixAtPosition("for(var i = 0, k=0; ;i++,k++)");
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedVariableInForLoop4FS.ts b/tests/cases/fourslash/unusedVariableInForLoop4FS.ts
new file mode 100644
index 00000000000..76e551612ba
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInForLoop4FS.ts
@@ -0,0 +1,10 @@
+///
+
+// @noUnusedLocals: true
+//// function f1 () {
+//// [|for(var i = 0, j= 0, k=0; ;j++, k++) |]{
+////
+//// }
+//// }
+
+verify.codeFixAtPosition("for(var j = 0, k=0; ;j++,k++)");
diff --git a/tests/cases/fourslash/unusedVariableInForLoop5FS.ts b/tests/cases/fourslash/unusedVariableInForLoop5FS.ts
new file mode 100644
index 00000000000..60369da522d
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInForLoop5FS.ts
@@ -0,0 +1,11 @@
+///
+
+// @noUnusedLocals: true
+//// function f1 () {
+//// for ([|const elem in|] ["a", "b", "c"]) {
+////
+//// }
+//// }
+
+verify.codeFixAtPosition("const {} in ");
+
diff --git a/tests/cases/fourslash/unusedVariableInForLoop6FS.ts b/tests/cases/fourslash/unusedVariableInForLoop6FS.ts
new file mode 100644
index 00000000000..4187c3141b5
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInForLoop6FS.ts
@@ -0,0 +1,11 @@
+///
+
+// @noUnusedLocals: true
+//// function f1 () {
+//// for ([|const elem of|] ["a", "b", "c"]) {
+////
+//// }
+//// }
+
+verify.codeFixAtPosition("const {} of ");
+
diff --git a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts
new file mode 100644
index 00000000000..8fd0fee735e
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts
@@ -0,0 +1,12 @@
+///
+
+// @noUnusedLocals: true
+//// function f1 () {
+//// for (const elem of ["a", "b", "c"]) {
+//// elem;
+//// [|var x = 20;|]
+//// }
+////}
+////
+
+verify.codeFixAtPosition("");
diff --git a/tests/cases/fourslash/unusedVariableInModule1.ts b/tests/cases/fourslash/unusedVariableInModule1.ts
new file mode 100644
index 00000000000..011434ce098
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInModule1.ts
@@ -0,0 +1,9 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters: true
+//// export {}
+//// [|var x: string;|]
+//// export var y: string;
+
+verify.codeFixAtPosition("");
diff --git a/tests/cases/fourslash/unusedVariableInModule2.ts b/tests/cases/fourslash/unusedVariableInModule2.ts
new file mode 100644
index 00000000000..09108ab1ee0
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInModule2.ts
@@ -0,0 +1,10 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters: true
+//// export {}
+//// [|var x: string, y: number;|]
+//// y;
+//// export var y: string;
+
+verify.codeFixAtPosition("var y: number;", 6133);
diff --git a/tests/cases/fourslash/unusedVariableInModule3.ts b/tests/cases/fourslash/unusedVariableInModule3.ts
new file mode 100644
index 00000000000..bffffc768d3
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInModule3.ts
@@ -0,0 +1,9 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters: true
+//// export {}
+//// [|var x = function f1() {}|]
+//// export var y: string;
+
+verify.codeFixAtPosition("");
diff --git a/tests/cases/fourslash/unusedVariableInModule4.ts b/tests/cases/fourslash/unusedVariableInModule4.ts
new file mode 100644
index 00000000000..6a1be9fe5b8
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInModule4.ts
@@ -0,0 +1,10 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters: true
+//// export {}
+//// [|var x = function f1(m: number) {}|]
+//// x;
+//// export var y: string;
+
+verify.codeFixAtPosition(`var x = function f1() {}`);
diff --git a/tests/cases/fourslash/unusedVariableInNamespace1.ts b/tests/cases/fourslash/unusedVariableInNamespace1.ts
new file mode 100644
index 00000000000..caf778bc0da
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInNamespace1.ts
@@ -0,0 +1,8 @@
+///
+
+// @noUnusedLocals: true
+////namespace greeter {
+//// [|let a = "dummy entry";|]
+////}
+
+verify.codeFixAtPosition("");
diff --git a/tests/cases/fourslash/unusedVariableInNamespace2.ts b/tests/cases/fourslash/unusedVariableInNamespace2.ts
new file mode 100644
index 00000000000..fbb9e2d6a0c
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInNamespace2.ts
@@ -0,0 +1,12 @@
+///
+
+// @noUnusedLocals: true
+////namespace greeter {
+//// [|let a = "dummy entry", b, c = 0;|]
+//// export function function1() {
+//// a = "dummy";
+//// c++;
+//// }
+////}
+
+verify.codeFixAtPosition(`let a = "dummy entry", c = 0;`);
diff --git a/tests/cases/fourslash/unusedVariableInNamespace3.ts b/tests/cases/fourslash/unusedVariableInNamespace3.ts
new file mode 100644
index 00000000000..33e501d0c0d
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInNamespace3.ts
@@ -0,0 +1,12 @@
+///
+
+// @noUnusedLocals: true
+////namespace greeter {
+//// [|let a = "dummy entry", b, c = 0;|]
+//// export function function1() {
+//// a = "dummy";
+//// b = 0;
+//// }
+////}
+
+verify.codeFixAtPosition(`let a = "dummy entry", b;`);