Выдаёт ошибку:
Uncaught TypeError: Super expression must either be null or a function, not undefined
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression mus...
Может быть есть какая то другая конструкция?
// Base.js module
export default class Base {
constructor () {
this.type = 'base';
}
}
// A.js module
import Base from './Base';
import getInstance from './getInstance';
export default class A extends Base {
constructor () {
super();
this.type = 'a';
this.n = 42;
}
someAction(value) {
value = getInstance(value);
return value.n + this.n;
}
}
// B.js module
import A from './A';
import getInstance from './getInstance';
export default class B extends A {
constructor () {
super();
this.type = 'b';
}
someAction(value) {
value = getInstance(value);
return value.n + this.n + 42;
}
}
//getInstance.js module
import A from './A';
import B from './B';
let check = (value) => {
let result = false;
if (value instanceof A || value instanceof B) {
result = true;
}
return result;
}
let getInstance = (value) => {
let result = value;
if(!check(value)) {
if (value === 'a') {
result = new A();
} else {
result = new B();
}
}
return result;
}
export default getInstance;