Some modifiers cannot be applied to class constructors:
class A {
static constructor()
abstract constructor()
async constructor()
readonly constructor() {}
}
Static constructor methods cannot be named constructor
as the constructor
property already exists on objects and refer to the constructor of the object.
create
is a common alternative name. Similarly, async
can be applied to a
static
"constructor". Marking a constructor as abstract
doesn't make sense
since abstract
only refers to members of the instance of a class. Constructors
cannot be assigned to, so readonly
doesn't make sense.
Fix:
Remove the constructor modifier:
class A {
static create(): A;
static async createAsync(): Promise<A>;
constructor() {}
}