In TypeScript the keywords constructor and new for member declarations are used to declare constructors in classes and interfaces respectively. However, a member declaration with the name new in an interface or constructor in a class, will declare an ordinary method named new or constructor rather than a constructor. Similarly, the keyword function is used to declare functions in some contexts. However, using the name function for a class or interface member declaration declares a method named function.

Declare classes as classes and not as interfaces. Use the keyword constructor to declare constructors in a class, use the keyword new to declare constructors inside interfaces, and don't use function when declaring a call signature in an interface.

The below example declares an interface Point with 2 fields and a method called constructor. The interface does not declare a class Point with a constructor, which was likely what the developer meant to create.

The below example is a fixed version of the above, where the interface is instead declared as a class, thereby describing the type the developer meant in the first place.

  • TypeScript specification: Constructor Type Literals.
  • TypeScript specification: Constructor Parameters.