Skip to content
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

[no-unused-vars] False positive with Decorators and Promises #2969

Closed
3 tasks done
msanguineti opened this issue Jan 24, 2021 · 1 comment
Closed
3 tasks done

[no-unused-vars] False positive with Decorators and Promises #2969

msanguineti opened this issue Jan 24, 2021 · 1 comment
Labels
duplicate This issue or pull request already exists package: parser Issues related to @typescript-eslint/parser

Comments

@msanguineti
Copy link

msanguineti commented Jan 24, 2021

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

# reproduction repo
git clone https://github.com/msanguineti/ts-eslint-test.git
# or
npx degit https://github.com/msanguineti/ts-eslint-test.git#main

.eslintrc.json

{
  "env": {
    "es2021": true,
    "node": true
  },
  "extends": [
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:@typescript-eslint/recommended-requiring-type-checking"
  ],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 12,
    "sourceType": "module",
    "project": "tsconfig.json"
  },
  "plugins": ["@typescript-eslint"],
  "rules": {}
}

index.ts

interface Message {
  body: string
}

const LogParameter = (): ParameterDecorator => {
  return (): void => {
    // ...
  }
}

export class Messenger {
  async deliverMessage(@LogParameter() message: string): Promise<Message> {
    return Promise.resolve({ body: message })
  }
}

tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "ES2018",
    "strict": true
  },
  "exclude": ["node_modules", "dist"]
}

Expected Result

No linting errors or warnings

Actual Result

  1:11  warning  'Message' is defined but never used  @typescript-eslint/no-unused-vars

Additional Info

This problem did not happen with @typescript-eslint/parser version 4.13.0. It only appeared in the last few days when I've upgraded the package to the latest version

Versions

package version
@typescript-eslint/parser 4.14.0
@typescript-eslint/eslint-plugin 4.14.0
TypeScript 4.1.3
ESLint 7.18.0
node 14.15.4
@msanguineti msanguineti added package: parser Issues related to @typescript-eslint/parser triage Waiting for maintainers to take a look labels Jan 24, 2021
@bradzacher
Copy link
Member

Same as #2941, #2942, #2945, #2947, #2950, #2957

Please use the search next time.

@bradzacher bradzacher added duplicate This issue or pull request already exists and removed triage Waiting for maintainers to take a look labels Jan 24, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists package: parser Issues related to @typescript-eslint/parser
Projects
None yet
Development

No branches or pull requests

2 participants