diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts
index 6ff4dccdee30e..f4fc7b8f009df 100644
--- a/src/harness/fourslash.ts
+++ b/src/harness/fourslash.ts
@@ -2013,13 +2013,13 @@ 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.");
}
const diagnostic = !errorCode ? diagnostics[0] : ts.find(diagnostics, d => d.code == errorCode);
- return this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [diagnostic.code]);
+ return this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.start + diagnostic.length, [diagnostic.code]);
}
public verifyCodeFixAtPosition(expectedText: string, errorCode?: number) {
diff --git a/src/services/codefixes/fixes.ts b/src/services/codefixes/fixes.ts
index d64a99ca1b9e6..ae13a9658387c 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 0000000000000..8e14bdcb73e26
--- /dev/null
+++ b/src/services/codefixes/unusedIdentifierFixes.ts
@@ -0,0 +1,167 @@
+/* @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;
+
+ let token = getTokenAtPosition(sourceFile, start);
+
+ // this handles var ["computed"] = 12;
+ if (token.kind === SyntaxKind.OpenBracketToken) {
+ token = getTokenAtPosition(sourceFile, start + 1);
+ }
+
+ switch (token.kind) {
+ case ts.SyntaxKind.Identifier:
+ switch (token.parent.kind) {
+ case ts.SyntaxKind.VariableDeclaration:
+ switch (token.parent.parent.parent.kind) {
+ case SyntaxKind.ForStatement:
+ const forStatement = token.parent.parent.parent;
+ const forInitializer = forStatement.initializer;
+ if (forInitializer.declarations.length === 1) {
+ return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos);
+ }
+ else {
+ return removeSingleItem(forInitializer.declarations, token);
+ }
+
+ case SyntaxKind.ForOfStatement:
+ const forOfStatement = token.parent.parent.parent;
+ if (forOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) {
+ const forOfInitializer = forOfStatement.initializer;
+ return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos);
+ }
+ break;
+
+ case SyntaxKind.ForInStatement:
+ // There is no valid fix in the case of:
+ // for .. in
+ return undefined;
+
+ case SyntaxKind.CatchClause:
+ const catchClause = token.parent.parent;
+ const parameter = catchClause.variableDeclaration.getChildren()[0];
+ return createCodeFix("", parameter.pos, parameter.end - parameter.pos);
+
+ default:
+ 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;
+ return removeSingleItem(declarations, token);
+ }
+ }
+
+ case 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 {
+ return removeSingleItem(typeParameters, token);
+ }
+
+ case 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 {
+ return removeSingleItem(functionDeclaration.parameters, token);
+ }
+
+ // handle case where 'import a = A;'
+ case SyntaxKind.ImportEqualsDeclaration:
+ const importEquals = findImportDeclaration(token);
+ return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos);
+
+ case SyntaxKind.ImportSpecifier:
+ const namedImports = token.parent.parent;
+ if (namedImports.elements.length === 1) {
+ // Only 1 import and it is unused. So the entire declaration should be removed.
+ const importSpec = findImportDeclaration(token);
+ return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos);
+ }
+ else {
+ return removeSingleItem(namedImports.elements, token);
+ }
+
+ // handle case where "import d, * as ns from './file'"
+ // or "'import {a, b as ns} from './file'"
+ case SyntaxKind.ImportClause: // this covers both 'import |d|' and 'import |d,| *'
+ const importClause = token.parent;
+ if (!importClause.namedBindings) { // |import d from './file'| or |import * as ns from './file'|
+ const importDecl = findImportDeclaration(importClause);
+ return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos);
+ }
+ else { // import |d,| * as ns from './file'
+ return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos);
+ }
+
+ case SyntaxKind.NamespaceImport:
+ const namespaceImport = token.parent;
+ if (namespaceImport.name == token && !(namespaceImport.parent).name) {
+ const importDecl = findImportDeclaration(namespaceImport);
+ return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos);
+ }
+ else {
+ const start = (namespaceImport.parent).name.end;
+ return createCodeFix("", start, (namespaceImport.parent).namedBindings.end - start);
+ }
+ }
+ break;
+
+ case SyntaxKind.PropertyDeclaration:
+ return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
+
+ case SyntaxKind.NamespaceImport:
+ return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
+ }
+ if (isDeclarationName(token)) {
+ return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
+ }
+ else if (isLiteralComputedPropertyDeclarationName(token)) {
+ return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos);
+ }
+ else {
+ return undefined;
+ }
+
+ function findImportDeclaration(token: Node): Node {
+ let importDecl = token;
+ while (importDecl.kind != SyntaxKind.ImportDeclaration && importDecl.parent) {
+ importDecl = importDecl.parent;
+ }
+
+ return importDecl;
+ }
+
+ 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 } }]
+ }]
+ }];
+ }
+
+ function removeSingleItem(elements: NodeArray, token: T): CodeAction[] {
+ 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);
+ }
+ }
+ }
+ });
+}
\ No newline at end of file
diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json
index a419877bcd863..502381b8be807 100644
--- a/src/services/tsconfig.json
+++ b/src/services/tsconfig.json
@@ -1,4 +1,4 @@
-{
+{
"compilerOptions": {
"noImplicitAny": true,
"noImplicitThis": true,
diff --git a/tests/cases/fourslash/unusedClassInNamespace1.ts b/tests/cases/fourslash/unusedClassInNamespace1.ts
new file mode 100644
index 0000000000000..586202ab0c7d4
--- /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 0000000000000..c182f4e3655dc
--- /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 0000000000000..391c5e833efac
--- /dev/null
+++ b/tests/cases/fourslash/unusedClassInNamespace3.ts
@@ -0,0 +1,25 @@
+///
+
+// @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/unusedClassInNamespace4.ts b/tests/cases/fourslash/unusedClassInNamespace4.ts
new file mode 100644
index 0000000000000..5db5b1aefa65d
--- /dev/null
+++ b/tests/cases/fourslash/unusedClassInNamespace4.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 0000000000000..df37325780997
--- /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 0000000000000..1d88f07ebf76b
--- /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/unusedEnumInNamespace1.ts b/tests/cases/fourslash/unusedEnumInNamespace1.ts
new file mode 100644
index 0000000000000..88e8e32d5f867
--- /dev/null
+++ b/tests/cases/fourslash/unusedEnumInNamespace1.ts
@@ -0,0 +1,11 @@
+///
+
+// @noUnusedLocals: true
+//// [| namespace greeter {
+//// enum enum1 {
+//// Monday
+//// }
+//// } |]
+
+verify.codeFixAtPosition(`namespace greeter {
+}`);
diff --git a/tests/cases/fourslash/unusedFunctionInNamespace1.ts b/tests/cases/fourslash/unusedFunctionInNamespace1.ts
new file mode 100644
index 0000000000000..e0f6b2e18ac15
--- /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 0000000000000..c823777048e2e
--- /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 0000000000000..144e9f325b444
--- /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 0000000000000..5b5995da9c745
--- /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 0000000000000..b839d9dcd976b
--- /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() {
+////
+//// }
+////
+//// export let a = function3; |]
+////}
+
+verify.codeFixAtPosition(`function function3() {
+ function1();
+ }
+
+ export let a = function3;`);
diff --git a/tests/cases/fourslash/unusedImports10FS.ts b/tests/cases/fourslash/unusedImports10FS.ts
new file mode 100644
index 0000000000000..f9d38e4cfb0ef
--- /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("");
+
diff --git a/tests/cases/fourslash/unusedImports11FS.ts b/tests/cases/fourslash/unusedImports11FS.ts
new file mode 100644
index 0000000000000..a18a4634d719b
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports11FS.ts
@@ -0,0 +1,14 @@
+///
+
+// @noUnusedLocals: true
+// @Filename: file2.ts
+//// [| import f1, * as s from "./file1"; |]
+//// s.f2('hello');
+
+// @Filename: file1.ts
+//// export var v1;
+//// export function f1(n: number){}
+//// export function f2(s: string){};
+//// export default f1;
+
+verify.codeFixAtPosition('import * as s from "./file1";');
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedImports12FS.ts b/tests/cases/fourslash/unusedImports12FS.ts
new file mode 100644
index 0000000000000..4d8243eb4abf0
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports12FS.ts
@@ -0,0 +1,13 @@
+///
+
+// @noUnusedLocals: true
+// @Filename: file2.ts
+//// [| import f1, * as s from "./file1"; |]
+//// f1(42);
+
+// @Filename: file1.ts
+//// export function f1(n: number){}
+//// export function f2(s: string){};
+//// export default f1;
+
+verify.codeFixAtPosition('import f1 from "./file1";');
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedImports1FS.ts b/tests/cases/fourslash/unusedImports1FS.ts
new file mode 100644
index 0000000000000..d9fc17a244846
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports1FS.ts
@@ -0,0 +1,12 @@
+///
+
+// @noUnusedLocals: true
+// @Filename: file2.ts
+//// [|import { Calculator } from "./file1" |]
+
+// @Filename: file1.ts
+//// export class Calculator {
+////
+//// }
+
+verify.codeFixAtPosition('');
diff --git a/tests/cases/fourslash/unusedImports2FS.ts b/tests/cases/fourslash/unusedImports2FS.ts
new file mode 100644
index 0000000000000..6e3d9527c52e2
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports2FS.ts
@@ -0,0 +1,19 @@
+///
+
+// @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"`);
diff --git a/tests/cases/fourslash/unusedImports3FS.ts b/tests/cases/fourslash/unusedImports3FS.ts
new file mode 100644
index 0000000000000..205666e971d84
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports3FS.ts
@@ -0,0 +1,24 @@
+///
+
+// @noUnusedLocals: true
+// @Filename: file2.ts
+////[| import {Calculator, 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 0000000000000..302007748f442
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports4FS.ts
@@ -0,0 +1,24 @@
+///
+
+// @noUnusedLocals: true
+// @Filename: file2.ts
+//// [| import {Calculator, test, 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 0000000000000..1d68f6ae64383
--- /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 0000000000000..a5c6744855af2
--- /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('');
\ 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 0000000000000..23066ef538d55
--- /dev/null
+++ b/tests/cases/fourslash/unusedImports7FS.ts
@@ -0,0 +1,16 @@
+///
+
+// @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('');
\ 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 0000000000000..02564e359895d
--- /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 0000000000000..324d57a1928c4
--- /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("");
\ 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 0000000000000..8d07a8c79121e
--- /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 0000000000000..baa46c65a0ce6
--- /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 0000000000000..2edd7c176e7dd
--- /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 0000000000000..b709432804118
--- /dev/null
+++ b/tests/cases/fourslash/unusedLocalsInFunction2.ts
@@ -0,0 +1,9 @@
+///
+
+// @noUnusedLocals: true
+////function greeter() {
+//// [| var x, y = 0; |]
+//// x+1;
+////}
+
+verify.codeFixAtPosition("var x;");
diff --git a/tests/cases/fourslash/unusedLocalsInFunction3.ts b/tests/cases/fourslash/unusedLocalsInFunction3.ts
new file mode 100644
index 0000000000000..906517ee0a78b
--- /dev/null
+++ b/tests/cases/fourslash/unusedLocalsInFunction3.ts
@@ -0,0 +1,10 @@
+///
+
+// @noUnusedLocals: true
+////function greeter() {
+//// [| var x, y = 0,z = 1; |]
+//// x+1;
+//// z+1;
+////}
+
+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 0000000000000..54d3223f23608
--- /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 0000000000000..43b782ce2661a
--- /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 0000000000000..322cfad394007
--- /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 0000000000000..412b599b780a9
--- /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 0000000000000..eff9b7c8d54b5
--- /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 0000000000000..7795a4d15303e
--- /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 0000000000000..24b6fe155efb5
--- /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 0000000000000..eab535fb5af66
--- /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 0000000000000..ee27ec331eb84
--- /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/unusedMethodInClass5.ts b/tests/cases/fourslash/unusedMethodInClass5.ts
new file mode 100644
index 0000000000000..36ef3670cac0e
--- /dev/null
+++ b/tests/cases/fourslash/unusedMethodInClass5.ts
@@ -0,0 +1,8 @@
+///
+
+// @noUnusedLocals: true
+//// [|class C {
+//// private ["string"] (){}
+//// }|]
+
+verify.codeFixAtPosition("class C { }");
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedMethodInClass6.ts b/tests/cases/fourslash/unusedMethodInClass6.ts
new file mode 100644
index 0000000000000..71fcb92d037b8
--- /dev/null
+++ b/tests/cases/fourslash/unusedMethodInClass6.ts
@@ -0,0 +1,8 @@
+///
+
+// @noUnusedLocals: true
+//// [|class C {
+//// private "string" (){}
+//// }|]
+
+verify.codeFixAtPosition("class C { }");
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedNamespaceInNamespace.ts b/tests/cases/fourslash/unusedNamespaceInNamespace.ts
new file mode 100644
index 0000000000000..41fe162ef1564
--- /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 0000000000000..f53c6d3e8bdde
--- /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/unusedParameterInConstructor2.ts b/tests/cases/fourslash/unusedParameterInConstructor2.ts
new file mode 100644
index 0000000000000..bd5f66ff96685
--- /dev/null
+++ b/tests/cases/fourslash/unusedParameterInConstructor2.ts
@@ -0,0 +1,8 @@
+///
+
+// @noUnusedLocals: true
+//// class C1 {
+//// [|constructor(public p1: string, private p2: boolean, public p3: any, p5)|] { p5; }
+//// }
+
+verify.codeFixAtPosition("constructor(public p1: string, public p3: any, p5)");
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedParameterInConstructor3.ts b/tests/cases/fourslash/unusedParameterInConstructor3.ts
new file mode 100644
index 0000000000000..173e00113d8f0
--- /dev/null
+++ b/tests/cases/fourslash/unusedParameterInConstructor3.ts
@@ -0,0 +1,8 @@
+///
+
+// @noUnusedLocals: true
+//// class C1 {
+//// [|constructor(public p1: string, public p2: boolean, private p3: any, p5)|] { p5; }
+//// }
+
+verify.codeFixAtPosition("constructor(public p1: string, public p2: boolean, p5)");
\ No newline at end of file
diff --git a/tests/cases/fourslash/unusedParameterInConstructor4.ts b/tests/cases/fourslash/unusedParameterInConstructor4.ts
new file mode 100644
index 0000000000000..6d0223dc5f4fd
--- /dev/null
+++ b/tests/cases/fourslash/unusedParameterInConstructor4.ts
@@ -0,0 +1,8 @@
+///
+
+// @noUnusedLocals: true
+//// class C1 {
+//// [|constructor(private readonly p2: boolean, p5)|] { p5; }
+//// }
+
+verify.codeFixAtPosition("constructor(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 0000000000000..2243af9f5f553
--- /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 0000000000000..493eafc572223
--- /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 0000000000000..6d79ba071b450
--- /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 0000000000000..b536543fb6d59
--- /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 0000000000000..c462b7425694d
--- /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/unusedTypeAliasInNamespace1.ts b/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts
new file mode 100644
index 0000000000000..593c0fe8cf433
--- /dev/null
+++ b/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts
@@ -0,0 +1,11 @@
+///
+
+// @noUnusedLocals: true
+//// [| namespace greeter {
+//// type hw = "Hello" |"world";
+//// export type nw = "No" | "Way";
+//// } |]
+
+verify.codeFixAtPosition(`namespace greeter {
+ export type nw = "No" | "Way";
+}`);
diff --git a/tests/cases/fourslash/unusedTypeParametersInClass1.ts b/tests/cases/fourslash/unusedTypeParametersInClass1.ts
new file mode 100644
index 0000000000000..ab654a5150e73
--- /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 0000000000000..8e860c10e049b
--- /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 0000000000000..75ae98f53e0ed
--- /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 0000000000000..7177ed41c8445
--- /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 0000000000000..344ae303c75df
--- /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 0000000000000..746b174db18d9
--- /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 0000000000000..70d8bc7800cd8
--- /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 0000000000000..73d7067236850
--- /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 0000000000000..77c802f5c44f3
--- /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 0000000000000..0ecb0338be2ce
--- /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 0000000000000..5a226fc9005ef
--- /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 0000000000000..7a9f04147d617
--- /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 0000000000000..3650cfbad98a0
--- /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 0000000000000..cb9b965ca4d45
--- /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 0000000000000..e9dedaef31eb0
--- /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 0000000000000..82bb99016efd5
--- /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 0000000000000..c971092584a53
--- /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 0000000000000..8d2a62e7175b9
--- /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 0000000000000..0ee02ab43632d
--- /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 0000000000000..1b1a0798c0445
--- /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 0000000000000..4eed9599b1513
--- /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 0000000000000..76e551612ba79
--- /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 0000000000000..23df03480e3ef
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInForLoop5FS.ts
@@ -0,0 +1,11 @@
+///
+
+// @noUnusedLocals: true
+//// function f1 () {
+//// for (const elem in ["a", "b", "c"]) {
+////
+//// }
+//// }
+
+verify.not.codeFixAvailable();
+
diff --git a/tests/cases/fourslash/unusedVariableInForLoop6FS.ts b/tests/cases/fourslash/unusedVariableInForLoop6FS.ts
new file mode 100644
index 0000000000000..4187c3141b547
--- /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 0000000000000..8fd0fee735e27
--- /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 0000000000000..011434ce098df
--- /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 0000000000000..db4519c8faac7
--- /dev/null
+++ b/tests/cases/fourslash/unusedVariableInModule2.ts
@@ -0,0 +1,10 @@
+///
+
+// @noUnusedLocals: true
+// @noUnusedParameters: true
+//// export {}
+//// [|var x: string, z: number;|]
+//// z;
+//// export var y: string;
+
+verify.codeFixAtPosition("var z: number;");
diff --git a/tests/cases/fourslash/unusedVariableInModule3.ts b/tests/cases/fourslash/unusedVariableInModule3.ts
new file mode 100644
index 0000000000000..bffffc768d355
--- /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 0000000000000..6a1be9fe5b89a
--- /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 0000000000000..caf778bc0da76
--- /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 0000000000000..fbb9e2d6a0c2b
--- /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 0000000000000..33e501d0c0def
--- /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;`);