Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[no-unused-vars] false positive when use imported type in JSX generic component #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
claneo opened this issue Jan 26, 2019 · 2 comments · Fixed by #150
Closed

[no-unused-vars] false positive when use imported type in JSX generic component #141

claneo opened this issue Jan 26, 2019 · 2 comments · Fixed by #150
Assignees
Labels
bug Something isn't working package: parser Issues related to @typescript-eslint/parser

Comments

@claneo
Copy link
Contributor

claneo commented Jan 26, 2019

Repro

{
  "rules": {
    "react/jsx-uses-vars": "error"
  },
  "plugins": [
    "react"
  ],
  "extends": "plugin:@typescript-eslint/recommended"
}
import React from 'react';
import { TypeA, TypeB } from './interface';

type TypeC = string;

class GenericComponent<P> extends React.Component {
    public internalProp: P;
}

export const a = <GenericComponent<TypeA> />;

export const b: TypeB = '';

export const c = <GenericComponent<TypeC> />;

Expected Result

no error

Actual Result

2:10 warning 'TypeA' is defined but never used @typescript-eslint/no-unused-vars

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 1.1.0
@typescript-eslint/parser 1.1.0
TypeScript 3.2.4
ESLint 5.12.1
node 10.14.1
npm 6.4.1
@claneo claneo added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Jan 26, 2019
@bradzacher bradzacher added duplicate This issue or pull request already exists wontfix This will not be worked on bug Something isn't working triage Waiting for team members to take a look and removed triage Waiting for team members to take a look duplicate This issue or pull request already exists wontfix This will not be worked on labels Jan 26, 2019
@bradzacher
Copy link
Member

bradzacher commented Jan 26, 2019

I think this is a duplicate of #111
We don't support JSX because it's supported in eslint-plugin-react

Though need to double check the AST for your example.


Reading through your config again, I'm wrong.
This looks like a weird interaction with generics?
I didn't even realise they'd added generic jsx syntax!

@armano2
Copy link
Collaborator

armano2 commented Jan 27, 2019

@bradzacher issue is with missing visitor keys, it's missing typeParameters in JSXOpeningFragment

@armano2 armano2 added package: parser Issues related to @typescript-eslint/parser and removed triage Waiting for team members to take a look package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin labels Jan 27, 2019
@armano2 armano2 self-assigned this Jan 27, 2019
uniqueiniquity pushed a commit to uniqueiniquity/typescript-eslint that referenced this issue Jan 28, 2019
This PR changes logic behind `no-use-before-define` to traverse all scopes

fixes: typescript-eslint#141
@typescript-eslint typescript-eslint locked as resolved and limited conversation to collaborators Feb 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: parser Issues related to @typescript-eslint/parser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants