Closed aiiak closed 11 months ago
Hi, @aiiak ,
Typescript definitions for translate
method moved to base class Shape
Hi, @alexbol99
Definition for translate method in base class stricktly define type of result object as Shape
class Shape {
translate(vec: Vector): Shape;
...
}
And we lose type after applying translate, for example
const p = new Flatten.Point(0,1).translate(1, 1);
Variable p will have type Shape, but shoul be Point
There is already some overrides for translate definition in index.d.ts , like for Polygon , Multiline and Matrix , f.e.
class Polygon {
...
translate(vec: Vector): Polygon;
...
}
So, this PR is make same override for Point class.
But if every method, defined in Shape class should return same object, that call method, following change in Shape definition should be more correct.
class Shape {
translate(vec: Vector): typeof this;
translate(x:number, y:number): typeof this;
rotate(angle: number, center?: Point): typeof this;
scale(scaleX: number, scaleY: number) : typeof this;
transform(matrix: Matrix): typeof this;
}
Fix typescript definitions for 'translate' metthod of Point class.