---
title: "JavaScript error \"Super Expression must either be null or a function\""
date: 2022-04-18T04:05:40-04:00
draft: true
toc: false
images:
tags:
  - dev
  - javascript
  - typescript
---

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.

```ts
// 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.
