8000 Bug: [consistent-type-imports] "used by decorator metadata" false positive for type used in constructor parameter · Issue #7327 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Bug: [consistent-type-imports] "used by decorator metadata" false positive for type used in constructor parameter #7327

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
4 tasks done
mpotthoff opened this issue Jul 27, 2023 · 2 comments · Fixed by #7334
Assignees
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: scope-manager Issues related to @typescript-eslint/scope-manager

Comments

@mpotthoff
Copy link

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Issue Description

When upgrading from typescript-eslint 5.x.x to 6.x.x I started seeing false positive errors "used by decorator metadata" for types that are used in constructor parameters, even if the class itself is not using any decorators at all.

So given these two files

export class ClassA {}
import type { ClassA } from "./classA";

export class ClassB {
    public constructor(classA: ClassA) {}
}

we would expect no errors, as no decorators are involved in either file.

Instead we get an error reported for the import of ClassA:

1:1  error  Type import "ClassA" is used by decorator metadata  @typescript-eslint/consistent-type-imports

Reproduction Repository Link

https://github.com/mpotthoff/consistent-type-imports-decorator-bug

Repro Steps

  1. clone the repo
  2. npm install
  3. npx eslint classB.ts

Versions

package version
@typescript-eslint/eslint-plugin 6.2.0
@typescript-eslint/parser 6.2.0
@typescript-eslint/scope-manager 6.2.0
@typescript-eslint/typescript-estree 6.2.0
@typescript-eslint/type-utils 6.2.0
@typescript-eslint/utils 6.2.0
TypeScript 5.1.6
ESLint 8.45.0
node 18.16.1
@mpotthoff mpotthoff added bug Something isn't working triage Waiting for team members to take a look labels Jul 27, 2023
@bradzacher
Copy link
Member

bug is this line here:

It was missed in #6274 (cc @JoshuaKGoldberg we need to turn on no-unnecessary-condition)

@bradzacher bradzacher added package: scope-manager Issues related to @typescript-eslint/scope-manager accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Jul 27, 2023
@JoshuaKGoldberg JoshuaKGoldberg self-assigned this Jul 27, 2023
@JoshuaKGoldberg
Copy link
Member

Oop. I fudged it, I'll fix it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working 4618 package: scope-manager Issues related to @typescript-eslint/scope-manager
Projects
None yet
3 participants
0