The analyzer has detected a property that references a field different from the one specified in the name.
The example:
class Vector2 {
constructor() {
this._x = 0;
this._y = 0;
}
get x() {
return this._x;
}
get y() {
return this._x; // <=
}
}
In the example, developers tried to declare the x and y properties to access the _x and _y fields, but the y property returns the wrong field.
The fixed code:
class Vector2 {
constructor() {
this._x = 0;
this._y = 0;
}
get x() {
return this._x;
}
get y() {
return this._y; // <=
}
}
The analyzer also issues a warning when the field and method names do not match:
class Rights {
constructor() {
this.read = false;
this.write = false;
}
setRead(value) {
this.read = value;
}
setWrite(value) {
this.read = value; // <=
}
}
Was this page helpful?