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
[prefer-readonly] False positive on fields within mixin classes #2590
Comments
Had a quick look and the bug occurs due to the type of the class that TS reports. |
Another example: export class Foo {
constructor(private bar: string) {
}
getBar(){
return this.bar;
}
setBar(){
this.bar = '';
}
} Rule says: |
this seem like issue with types produced by typescript, generally i do not like that this rule is using type checking, as there should no be a need for it, we could achieve all of this by doing static code analysis,
in this case, typescript returns us IntersectionType without symbol in typeFlags we are receiving |
Repro
Using the repo code from https://github.com/WGroenestein/typescript-eslint-prefer-readonly-class-mixin
Expected Result
Fields which are assigned outside the constructor (e.g. setters) in mixin classes are not marked as not assigned / readonly
Actual Result
They are reported as errors, and when running --fix it breaks the build
Additional Info
The debug log can be found in the repo (https://github.com/WGroenestein/typescript-eslint-prefer-readonly-class-mixin/blob/master/debug.log)
Versions
@typescript-eslint/eslint-plugin
4.2.0
@typescript-eslint/parser
4.2.0
TypeScript
4.0.3
ESLint
7.9.0
node
12.18.3
The text was updated successfully, but these errors were encountered: