Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
Description
- 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
package.json
{"private":true,"dependencies": {"@typescript-eslint/eslint-plugin":"^4.14.0","@typescript-eslint/parser":"^4.14.0","eslint":"^7.18.0","typescript":"^4.1.3" },"eslintConfig": {"parser":"@typescript-eslint/parser","plugins": ["@typescript-eslint" ],"extends": ["eslint:recommended","plugin:@typescript-eslint/recommended" ] }}input.ts
letn=0;exportclassC{constructor(publicreadonlyx=++n){}}
tsconfig.json
{"compilerOptions": {"strict":true,"target":"ES2019" },"files": ["input.ts" ]}Expected Result
./node_modules/.bin/eslint input.js should give no error.
Actual Result
$ ./node_modules/.bin/eslint input.tsC:\Users\sunny\Documents\code\eslint-bug-prefer-const\input.ts 1:5 error 'n' is never reassigned. Use 'const' instead prefer-const✖ 1 problem (1 error, 0 warnings) 1 error and 0 warnings potentially fixable with the `--fix` option.If I use--fix, thelet would be changed toconst, and TypeScript will report compilation error.
Additional Info
Compiledinput.js
letn=0;exportclassC{constructor(x=++n){this.x=x;}}
./node_modules/.bin/eslint input.js gives no error.
Versions
| package | version |
|---|---|
@typescript-eslint/eslint-plugin | 4.14.0 |
@typescript-eslint/parser | 4.14.0 |
TypeScript | 4.1.3 |
ESLint | 7.18.0 |
node | 15.5.1 |
This issue did not occur 3 days ago (2021-01-17). All of typescript-eslint, TypeScript, and ESLint had upgrades during this period of time. Downgrading typescript-eslint to 4.13.0 (but not downgrading other packages) seem to solve this problem. Thus, this is a regression.