Skip to content

[no-use-before-define] Typescript Optional Chaining False Positive #1182

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
Skillz4Killz opened this issue Nov 7, 2019 · 1 comment
Closed
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@Skillz4Killz
Copy link

Skillz4Killz commented Nov 7, 2019

Repro

{
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 2019,
    "sourceType": "module"
  },
  "extends": ["plugin:@typescript-eslint/recommended", "prettier/@typescript-eslint", "plugin:prettier/recommended"],
  "rules": {
    "@typescript-eslint/explicit-function-return-type": "off"
  }
}
const language = guildSettings?.language || `en-US`

Expected Result
This should not throw an error as it is valid syntax.

Actual Result
It throws a false positive error thinking that the language variable is being used but its actually a property call using the new Typescript optional chaining in 3.7 version.

Additional Info

46:50  error  'language' was used before it was defined  @typescript-eslint/no-use-before-define

✖ 1 problem (1 error, 0 warnings)

Versions

package version
@typescript-eslint/eslint-plugin 2.6.1
@typescript-eslint/parser 2.6.1
TypeScript 3.7.2
ESLint 6.5.1
node 12.13.0
npm 6.12.0
@Skillz4Killz Skillz4Killz added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Nov 7, 2019
@bradzacher bradzacher added duplicate This issue or pull request already exists and removed triage Waiting for team members to take a look labels Nov 7, 2019
@bradzacher
Copy link
Member

Duplicate of #1104

Please use the search

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
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: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

2 participants