mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 01:49:57 -05:00
Add more testcases and simplify
This commit is contained in:
@@ -54,14 +54,6 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
|
||||
|
||||
case SyntaxKind.TypeParameter:
|
||||
const typeParameters = (<DeclarationWithTypeParameters>token.parent.parent).typeParameters;
|
||||
if (typeParameters.length === 1) {
|
||||
@@ -105,6 +97,12 @@ namespace ts.codefix {
|
||||
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
|
||||
|
||||
default:
|
||||
if (isDeclarationName(token)) {
|
||||
return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -5,8 +5,21 @@
|
||||
//// [| namespace Validation {
|
||||
//// class c1 {
|
||||
////
|
||||
//// }/*1*/
|
||||
//// } |]
|
||||
//// }
|
||||
////
|
||||
//// export class c2 {
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// class c3 extends c1 {
|
||||
////
|
||||
//// }
|
||||
////} |]
|
||||
|
||||
verify.codeFixAtPosition(`namespace Validation {
|
||||
}`);
|
||||
class c1 {
|
||||
}
|
||||
|
||||
export class c2 {
|
||||
}
|
||||
}`);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
// @noUnusedLocals: true
|
||||
// @noUnusedParameters:true
|
||||
|
||||
//// [| namespace Validation {
|
||||
//// class c1 {
|
||||
////
|
||||
@@ -11,9 +10,18 @@
|
||||
//// export class c2 {
|
||||
////
|
||||
//// }
|
||||
//// } |]
|
||||
////
|
||||
//// class c3 {
|
||||
//// public x: c1;
|
||||
//// }
|
||||
////} |]
|
||||
|
||||
verify.codeFixAtPosition(`namespace Validation {
|
||||
class c1 {
|
||||
|
||||
}
|
||||
|
||||
export class c2 {
|
||||
|
||||
}
|
||||
}`);
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @noUnusedLocals: true
|
||||
// @noUnusedParameters:true
|
||||
|
||||
//// [| namespace Validation {
|
||||
//// class c1 {
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// export class c2 {
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// class c3 extends c1 {
|
||||
////
|
||||
//// }
|
||||
////} |]
|
||||
|
||||
verify.codeFixAtPosition(`namespace Validation {
|
||||
class c1 {
|
||||
}
|
||||
|
||||
export class c2 {
|
||||
}
|
||||
}`);
|
||||
@@ -1,27 +0,0 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @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 {
|
||||
|
||||
}
|
||||
}`);
|
||||
11
tests/cases/fourslash/unusedEnumInNamespace1.ts
Normal file
11
tests/cases/fourslash/unusedEnumInNamespace1.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @noUnusedLocals: true
|
||||
//// [| namespace greeter {
|
||||
//// enum enum1 {
|
||||
//// Monday
|
||||
//// }
|
||||
//// } |]
|
||||
|
||||
verify.codeFixAtPosition(`namespace greeter {
|
||||
}`);
|
||||
11
tests/cases/fourslash/unusedTypeAliasInNamespace1.ts
Normal file
11
tests/cases/fourslash/unusedTypeAliasInNamespace1.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @noUnusedLocals: true
|
||||
//// [| namespace greeter {
|
||||
//// type hw = "Hello" |"world";
|
||||
//// export type nw = "No" | "Way";
|
||||
//// } |]
|
||||
|
||||
verify.codeFixAtPosition(`namespace greeter {
|
||||
export type nw = "No" | "Way";
|
||||
}`);
|
||||
Reference in New Issue
Block a user