justinfagnani / mixwith.js

A mixin library for ES6

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error TS2339: Property 'emit' does not exist on type 'MyClass2'.

khusamov opened this issue · comments

Hello!

The following code does not work. How do I fix this error?

import * as EventEmitter from 'events';

let MyMixin = Mixin((superclass) => class extends superclass {

  foo() {
    console.log('foo from MyMixin');
    super.foo();
  }

});

class MyClass extends mix(EventEmitter).with(MyMixin) {

  foo() {
    console.log('foo from MyClass');
    super.foo(); 
  }

}


class MyClass2 extends MyClass {
    
    method1() {
        this.emit('event1'); // error TS2339: Property 'emit' does not exist on type 'MyClass2'.
    }
    
}

const io = require('socket.io')(server);
this.io.emit('data', { data: value });