I’m working on a Vue app and trying to build some helper classes:
file a.js:
export default class Base {//...}
file b.js:
import Base from "./a" export default class Middle extends Base { // ... }
file c.js:
import Middle from "./b" // Middle here is undefined export default class Final extends Middle { // ... }}
When I import Middle it is undefined and giving me Uncaught TypeError: Super expression must either be null or a function
on the line of extends Middle
I’ve also tried
let Middle = class Middle .... export default Middle
Which should not make a difference as far as I know and it didn’t solve the problem..
I’m building a component as a standalone library with:
vue-cli-service build –target lib
Advertisement
Answer
Finally I found out that it was some kind of recursion. In the Base
class I had a factory method that interprets a JSON and returns the corresponding Final
class. This of course means I had to import the Final classes in the Base class’ file.