Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Imported interfaces are considered not used by no-unused-vars rule #223

Closed
mattdell opened this issue Apr 18, 2017 · 7 comments
Closed

Imported interfaces are considered not used by no-unused-vars rule #223

mattdell opened this issue Apr 18, 2017 · 7 comments

Comments

@mattdell
Copy link

What version of TypeScript are you using?
2.2.2

What version of typescript-eslint-parser are you using?
2.1.0

What code were you trying to parse?

import SearchResult, { ISearchResultProps } from '../../components/SearchResult';

class SearchResultContainer extends React.Component<any, any> {
   render() {
        const { value, suggestions } = this.state;

        const searchResultProps: ISearchResultProps = {
            foo,
            bar,
        };

        return (
            <SearchResult {searchResultProps} />
        );
    }
}

What did you expect to happen?
All to be right with the world

What happened?
[eslint] 'ISearchResultProps' is defined but never used. (no-unused-vars)

@soda0289
Copy link
Member

This is a known issue and has been covered in here:
#77

The reason it fails is because the scope analysis tool does not traverse type annotations or decorators and will not mark these as references. I have put a proposal for a possible fix but more though needs to go into a long term solution.
eslint/eslint-scope#30

The work around is to use the typescript compiler options:

  • noUnusedLocals
  • noUnusedParameters

or use the typescript plugin rule

  • no-unused-vars

I should update the README with a list of known issues as this is a frequently observed problem.

@mattdell
Copy link
Author

Excellent response. Thank you very much.

I'll probably look into the ts plugin rule.

@soda0289
Copy link
Member

@mattdell The version on npm is really outdated. You need to install from the master branch.

npm install nzakas/eslint-plugin-typescript should do the trick

@mattdell
Copy link
Author

Ah. That makes sense. Unfortunately my work blocks us from having github dependencies as only npmjs.org goes through the proxy.

Alas, that is my problem not yours. Thanks for the suggestion. 😄

@platinumazure
Copy link
Member

@soda0289 Do we need to publish a new release of eslint-plugin-typescript? Or does it need to be changed to align with changes made here and in eslint-scope and other areas before a release can occur?

@soda0289
Copy link
Member

@platinumazure The eslint typescript plugin has only had one release and many rules have been added or updated since. There is nothing in the parser or eslint-scope that is blocking a release. I noticed on the npmjs page that eslint tsc members are 'Collaborators'. Does this mean they can publish a new release?

@platinumazure
Copy link
Member

@soda0289 Yes, the ESLint TSC should be able to do a release of that project, hopefully. Feel free to ask in the team Gitter chat.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants