简体   繁体   中英

Declaring events in a TypeScript class which extends an abstract class that extends EventEmitter

export default abstract class Conference extends EventEmitter {
    constructor() {
        super();
    }
    ...
}

export default class ConferenceHMS extends Conference {
    constructor() {
        super();
        this.emit('eventName', eventArgument);
    }
}

So I have a class ConferenceHMS that extends another abstract class Conference that extends EventEmitter. I want type definitions for the emit and on methods. I've used all the approaches specified in this related question but they don't seem to work.

Answering my own question since I found a solution that worked for me. It seemed that the error resolved itself once I changed my imports from '../someFile.ts' to '../someFile'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM