class SomethingNotConstructible {
private constructor() {}
}
with tslint.json configuration:
{
"rules": {
"unnecessary-constructor": true
}
}
The private constructor is flagged as unnecessary.
The private constructor is not flagged.
There are cases where a class shouldn't be constructible (factory classes or something) where it would make sense to have an empty constructor with the private/etc modifier to prevent it from being constructed externally. Right now, this private empty constructor is flagged by the unnecessary-constructor rule. In my estimation, this constructor _is_ necessary, because it performs a task that would not performed were it not included (makes the constructor inaccessible).
Agreed, thanks for the catch @ericbf!
This should be a pretty straightforward change: the rule should also check if there's a privacy modifier on the constructor other than public.
hello, i am new to this open source world but have been coding in js and typescript for around 2-3 years now. i can look into this bug and if possible can make necessary changes to it.
so can i start working on it ?
@nirajgeorgian Absolutely
Most helpful comment
hello, i am new to this open source world but have been coding in js and typescript for around 2-3 years now. i can look into this bug and if possible can make necessary changes to it.
so can i start working on it ?