Type X is not a 'constructor function type' (TS2507)

Bruno Grieder picture Bruno Grieder · Nov 6, 2015 · Viewed 12k times · Source

While designing a definition file, I came across this error (TS2507).

How can I specify a type to be a 'constructor function type' ?

Answer

JKillian picture JKillian · Nov 6, 2015

If you are defining an interface, you can declare that it is a constructor like such:

interface SomeInterface {
  new(someParam: any): SomeInterface
}

This is useful when you are defining typings for already existing JS libraries. See this SO answer for more details.