Closed
Description
Repro
{
"rules": {
"@typescript-eslint/restrict-plus-operands": "error"
}
}
namespace Other {
export abstract class ILegend
{
protected legendWidth: number = 244;
public get width(): number { return this.legendWidth; }
}
export class Canvas
{
protected width: number;
}
export class FoLegend extends ILegend
{
}
export class Legend extends ILegend
{
}
export abstract class Chart extends Canvas
{
protected static readonly svgcMargin: number = 10;
protected legend: ILegend;
constructor(foreignObjectSupported: boolean)
{
super();
if (foreignObjectSupported)
this.legend = new FoLegend();
else
this.legend = new Legend();
}
// This is the line it should error on.
protected get legendXPosition(): number { return this.width - (Chart.svgcMargin + this.legend.width); }
}
export class PieChart extends Chart
{
public getAvailableWidth(): number
{
// This is the line it should error on.
return this.width - (this.legend.width + Chart.svgcMargin);
}
}
export class BarChart extends Chart
{
public getAvailableWidth(): number
{
// This is the line it should error on.
return this.width - (this.legend.width + Chart.svgcMargin);
}
}
export class PointChart extends Chart
{
public getAvailableWidth(): number
{
// This is the line it should error on.
return this.width - (this.legend.width + Chart.svgcMargin);
}
}
}
Expected Result
No error
Actual Result
this.legend.width + Chart.svgcMargin
reports a false positive
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
1.10.2 |
@typescript-eslint/parser |
1.10.2 |
TypeScript |
3.4.3 |
ESLint |
5.16.0 |