Description
Description
I am having an issue with class inheritance and I am not sure if it is a bug or something that I misunderstand.
The situation goes like so: I have a generic class called Base, This class is extended to create a notification class. I have another class used for event dispatching, which dispatches events to the notification class. The base class has an instance of the event dispatcher. Finally, I have another class the extends Base that will send events to the dispatcher called EventSend.
The problem is if all of these four classes are defined in separate files I get a type error
TypeError: Class extends value undefined is not a constructor or null
However, If I bring the notification class into the base class file it compiles and works fine.
//test file
import 'reflect-metadata';
import { Container } from '../../../src/index';
import { EventSend } from './eventsend';
describe('Github Issue', function () {
it('My Issue', () => {
const eventSend = Container.get(EventSend);
});
});
// dispatcher.ts
import { Inject, Service } from '../../../src';
import { Notifications } from './notifications';
@Service()
export class Dispatcher {
@Inject(() => Notifications)
notifications: Notifications
}
// notifications.ts
import { Service } from '../../../src';
import { Base } from './base';
@Service()
export class Notifications extends Base {}
// event-send.ts
import { Service } from '../../../src';
import { Base } from './base';
@Service()
export class EventSend extends Base {}
// base.ts
import { Inject, Service } from '../../../src';
import { Dispatcher } from './dispatcher';
@Service()
export class Base {
@Inject(() => Dispatcher)
public dispatcher: Dispatcher
}
Expected behavior
I would hope this can work with not having my subclass defined in the same file
Actual behavior
Throws error TypeError: Class extends value undefined is not a constructor or null