Answer the question
In order to leave comments, you need to log in
How correctly to register types through Flow?
I have a class for which I need to write types
class Point {
constructor(x:number, y:number) {
if (arguments.length > 2 || arguments.length < 2) {
throw new Error('You send more or less arguments')
}
this.x = x;
this.y = y;
}
static randomNumber(from:number, to:number) {
if (arguments.length > 2 || arguments.length < 2) {
throw new Error('You send more or less arguments')
}
return Math.random() * (to - from) + from;
}
static randomPoint(xFrom:number, xTo:number, yFrom:number, yTo:number) {
if (arguments.length > 4 || arguments.length < 4) {
throw new Error('You send more or less arguments')
}
return new Point(
Point.randomNumber(xFrom, xTo), Point.randomNumber(yFrom, yTo)
)
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question