NodeJS EventEmitter with TypeScript class
You should download node typings:
$ tsd install node --save
and then just use the following code:
///<reference path="./typings/node/node.d.ts" />
import events = require('events');
class Database{
constructor() {
events.EventEmitter.call(this);
}
}
I simplified it to test your main problem.
Edit: Modified based on your comment:
///<reference path="./typings/node/node.d.ts" />
import events = require('events');
class Database extends events.EventEmitter {
constructor() {
super();
this.emit('ready');
}
}
new Database();
New approach:
///<reference path="./typings/node/node.d.ts" />
import {EventEmitter} from 'events';
class Database extends EventEmitter {
constructor() {
super();
this.emit('ready');
}
}
new Database();
The modern way to download types definitions for NodeJS and EventEmitter particularly is yarn add @types/node
or npm install @types/node