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
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I havesearched for related issues and found none that matched my issue.
- I haveread the FAQ and my problem is not listed.
Playground Link
Repro Code
classTest{publicneedsToBeDefined?:number;privatenotReadonlyFoo?:number;privatenotReadonlyBar?:number;publictestMethodFoo(){if(!this.classPropertyGuard()){return;}this.notReadonlyFoo=1;}publictestMethodBar(){if(!this.normalTypeGuard(this.needsToBeDefined)){return;}this.notReadonlyBar=2;}privateclassPropertyGuard():this is this&{needsToBeDefined:number}{returnthis.needsToBeDefined!==undefined;}privatenormalTypeGuard(value:number|undefined):value isnumber{returnvalue!==undefined;}}
ESLint Config
module.exports={parser:"@typescript-eslint/parser",rules:{"@typescript-eslint/prefer-readonly":"error"},};
tsconfig
No response
Expected Result
I expected thatprivate notReadonlyFoo?: number;
would not report any errors.
Actual Result
@typescript-eslint/prefer-readonly
error on the 4th line:
Member 'notReadonlyFoo' is never reassigned; mark it as `readonly`. 4:3 - 4:35
Additional Info
No response