Bug Report
π Search Terms
private/public class property order
π Version & Regression Information
- This is the behavior in every version from 4.3.5 to 4.7.4
β― Playground Link
Playground link with relevant code
π» Code
// Example without error
class User {
#name!: string;
public get name() {
return this.#name;
}
private set name(name: string) {
this.#name = name;
}
}
const user = new User();
// no error
user.name;
// Example with error
class UserError {
#name!: string;
private set name(name: string) {
this.#name = name;
}
public get name() {
return this.#name;
}
}
const userError = new UserError();
// error: Property 'name' is private and only accessible within class 'UserError'.
userError.name;
π Actual behavior
If we firstly define a private setter for a property and then a public getter for the same property we receive an error when accessing the getter - Property is private and only accessible within class. If we change the order the error doesn't appear
π Expected behavior
Any order is acceptable and doesn't produce an error
Bug Report
π Search Terms
private/public class property order
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
If we firstly define a private setter for a property and then a public getter for the same property we receive an error when accessing the getter -
Property is private and only accessible within class. If we change the order the error doesn't appearπ Expected behavior
Any order is acceptable and doesn't produce an error