Closed
Description
TypeScript 3.8 will add support for private named instance fields. What about creating a rule for disallowing the use of the private
accessibility modifier in favor of the standard hash names for private members?
Examples of incorrect code for this rule:
class MyClass {
private foo = 1;
constructor(private bar: string) {}
}
Examples of correct code for this rule:
class MyClass {
#foo = 1;
#bar: string;
constructor(bar: string) {
this.#bar = bar;
}
}
Options
// Any target whose hash names are supported
// by the TypeScript version in use can be specified
type Target =
// | 'accessors'
// | 'constructors'
// | 'staticMethods'
// | 'instanceMethods'
// | 'staticFields'
| 'instanceFields';
type Options = Target[];
// Defaults to all the targets
const defaultOptions: Options = ['instanceFields']; // for TypeScript 3.8