Tslint: implemented interface is declared but its value is never read.

Created on 16 Nov 2017  路  8Comments  路  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.8.0
  • __TypeScript version__: 2.5.0
  • __Running TSLint via__: VSCode

Ioinic : 3.9.0

TypeScript code being linted

import { Component, Input, OnInit, OnDestroy } from '@angular/core';
export class PageBottom implements OnInit, OnDestroy {

    constructor(private appService: AppService) {
    }

    ngOnInit() {
        ...
    }
       ngOnDestroy() {
        ...
    }

}

with tslint.json configuration:

{
  "enable": true,
  "rules": {
    "no-duplicate-variable": true,
    "no-unused-variable": [
      true
    ]
  },
  "rulesDirectory": [
    "node_modules/tslint-eslint-rules/dist/rules"
  ],
  "autoFixOnSave": true
}

Actual behavior

'OnInit' is declared but its value is never read.
'OnDestroy' is declared but its value is never read.

Expected behavior

No errors

External Bug

Most helpful comment

Do you get the same errors when you enable compilerOptions.noUnusedLocals in your tsconfig.json?

All 8 comments

Looks like a duplicate of #3463

Can you try upgrading to [email protected]? That fixed a similar issue.

Updated to 2.6.1 and still the same warnings

Do you get the same errors when you enable compilerOptions.noUnusedLocals in your tsconfig.json?

yes, it looks like it's not recognizing that I have implemented OnInit.

That might be a bug in TypeScript. no-unused-variable uses TypeScript's implementation of --noUnusedLocals and --noUnusedParameters behind the scenes.
If you can narrow this down to a self-contained reproduction, I suggest reporting it in the TypeScript repository.

This is a bug for me too

TSLint version: 5.8.0
TypeScript version: 2.6.2
Running TSLint via: Node.js API

Same for me

TSLint version: 5.9.1
TypeScript version: 2.6.2
Running TSLint via: Node.js API

As ajafff mentioned, no-unused-variable directly reports TypeScript's diagnostics. Please file an issue on the TypeScript issue tracker if you're seeing these bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rajinder-yadav picture rajinder-yadav  路  3Comments

denkomanceski picture denkomanceski  路  3Comments

avanderhoorn picture avanderhoorn  路  3Comments

DanielKucal picture DanielKucal  路  3Comments

ghost picture ghost  路  3Comments