Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[prefer-const] False positives when using non-nullish assertion operator #2804

Closed
Labels
bugSomething isn't workingpackage: scope-managerIssues related to @typescript-eslint/scope-manager
@almeidx

Description

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

Repro

// ESLint says: 'num' is never reassigned. Use 'const' instead.letnum=data?.anum!=1// same thing happens with +=, -=, etc
{"rules": {"prefer-const":"error"  }}
// your repro code caseletxp=data?.xp;/* bunch of unrelated code ... */xp!=123;

Expected Result

Nothing, sincenum is being reassigned

Actual Result

ESLint says'xp' is never reassigned. Use 'const' instead.

Additional Info

Versions

packageversion
@typescript-eslint/eslint-plugin4.6.0
@typescript-eslint/parser4.6.0
TypeScript4.1.2
ESLint7.14.0
node14.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: scope-managerIssues related to @typescript-eslint/scope-manager

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp