So I\'m trying to extend a class in node js and the compiler keeps returning the following error:
TypeError: Class extends value #
In my instance, it was the same issue as @James111 was experiencing (circular import) due to a factory pattern I was trying to set up in Typescript. My fix was to do move the code into files, similar to the following:
// ./src/interface.ts
import { ConcreteClass } from './concrete';
export interface BaseInterface {
someFunction(): any;
}
export class Factory {
static build(): BaseInterface {
return new ConcreteClass();
}
}
// ./src/base.ts
import { BaseInterface } from './interface';
class BaseClass implements BaseInterface {
someFunction(): any {
return true;
}
}
// ./src/concrete.ts
import { BaseClass } from './base';
export class ConcreteClass extends BaseClass {
someFunction(): any {
return false;
}
}
So it turns out I had a circular reference in my code, where I was importing
the class that was extending, into the class that itself was extending (tongue twister :P).
The obvious fix was to simply remove the extends
reference and find another way of doing what I was trying to achieve. In my case it was passing the Venue
class properties down into the VenueViews
constructor.
E.g var x = VenueViews(this)