I just got this error when working on some TypeScript code.

Uncaught TypeError: Super Expression must either be null or a function

The line for the error pointed to the constructor of a class. What’s happening? Circular dependencies it turns out.

// in foo.ts
class Foo {
  foo() {
    new Bar().doSomething();
  }
}

// in bar.ts
class Bar extends Foo {
  // ...
}

It’s obvious when boiled down like this, but it’s something you’ll want to make sure to avoid. I solved this issue by making Bar not extend Foo. It added little to no duplicated code for me in this case, so just separating the classes was easy enough.