Skip to content

Commit

Permalink
fix(unused): Support interfaces and type aliases.
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed Apr 12, 2019
1 parent 2980e01 commit bdc71ba
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fixtures/no-unused-declaration/unused-types/fixture.ts.fix
@@ -1,2 +1,3 @@
class Person {}
interface SomeInterface {}
type SomeType = {};

24 changes: 24 additions & 0 deletions source/rules/noUnusedDeclarationRule.ts
Expand Up @@ -144,6 +144,18 @@ export class Walker extends Lint.ProgramAwareRuleWalker {
super.visitImportDeclaration(node);
}

protected visitInterfaceDeclaration(node: ts.InterfaceDeclaration): void {

if (this._validate.declarations) {
const { name } = node;
if (!tsutils.hasModifier(node.modifiers, ts.SyntaxKind.ExportKeyword)) {
this.declared(node, name);
this.setScopedIdentifier(name);
}
}
super.visitInterfaceDeclaration(node);
}

protected visitJsxSelfClosingElement(node: ts.JsxSelfClosingElement): void {

this.seenJsx();
Expand Down Expand Up @@ -223,6 +235,18 @@ export class Walker extends Lint.ProgramAwareRuleWalker {
super.visitObjectLiteralExpression(node);
}

protected visitTypeAliasDeclaration(node: ts.TypeAliasDeclaration): void {

if (this._validate.declarations) {
const { name } = node;
if (!tsutils.hasModifier(node.modifiers, ts.SyntaxKind.ExportKeyword)) {
this.declared(node, name);
this.setScopedIdentifier(name);
}
}
super.visitTypeAliasDeclaration(node);
}

protected visitVariableStatement(node: ts.VariableStatement): void {

if (this._validate.declarations) {
Expand Down

0 comments on commit bdc71ba

Please sign in to comment.