-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[prefer-const] False positives when using non-nullish assertion operator #2804
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
Comments
Your example shows that I think maybe you're misunderstanding the lint rule and how The rule isn't saying "num must be assigned to a different variable". Example:
|
@bradzacher The error I mentioned in the Actual Result was the error from the minimal repro code. The error on my use case is Anyways, I edited the description of the issue to maybe make it more clear |
Why are you assigning to |
okay... so your example again is incorrect. Your example should actually be let xp: number | undefined = 1;
xp! += 1; If you ensure your initial example and error message are together a completely isolated reproduction of your problem, then we can save all this back-and-forth next time. That's the entire point of the template. |
Alright, sorry for the trouble. 😅 |
Repro
Expected Result
Nothing, since
num
is being reassignedActual Result
ESLint says
'xp' is never reassigned. Use 'const' instead.
Additional Info
Versions
@typescript-eslint/eslint-plugin
4.6.0
@typescript-eslint/parser
4.6.0
TypeScript
4.1.2
ESLint
7.14.0
node
14.14.0
The text was updated successfully, but these errors were encountered: