import StrictEventEmitter , { StrictBroadcast , EventNames , OnEventNames , EmitEventNames } from '../src/index' ; interface Position { x : number ; y : number ; } interface Events { move : Position ; done : void ; } interface Emitables { moveRequest : Position ; stop : void ; } import { EventEmitter } from 'events' ; let eei = new EventEmitter ( ) ; function cb ( p ) { } let v = eei . on ( 'move' , v => v . x + v . y ) ; v . on ( 'done' , function ( ) { } ) ; eei . emit ( 'move' , { x : 1 , y : 2 } ) ; eei . emit ( 'done' ) ; eei . addListener ( 'move' , cb ) ; eei . addListener ( 'done' , function ( ) { } ) ; eei . once ( 'move' , v => v . x + v . y ) ; eei . once ( 'done' , function ( ) { } ) ; eei . removeListener ( 'move' , cb ) ; eei . removeListener ( 'done' , function ( ) { } ) ; eei . emit ( 'move' , { x : 1 , y : 2 } ) ; eei . emit ( 'done' ) ; let eventNames ; eventNames = 'move' ; eventNames = 'done' ; let eei2 = new EventEmitter ( ) ; eei2 . on ( 'move' , v => v . x + v . y ) ; eei2 . on ( 'done' , function ( ) { } ) ; eei2 . addListener ( 'move' , v => v . x + v . y ) ; eei2 . addListener ( 'done' , function ( ) { } ) ; eei2 . once ( 'move' , v => v . x + v . y ) ; eei2 . once ( 'done' , function ( ) { } ) ; eei2 . removeListener ( 'move' , cb ) ; eei2 . removeListener ( 'done' , function ( ) { } ) ; eei2 . emit ( 'moveRequest' , { x : 1 , y : 2 } ) ; eei2 . emit ( 'stop' ) ; let names ; names = 'move' ; names = 'done' ; names = 'moveRequest' ; names = 'stop' ; let emitNames ; emitNames = 'moveRequest' ; emitNames = 'stop' ; let onNames ; onNames = 'move' ; onNames = 'done' ; var broadcast = function ( e , payload ? ) { if ( e === 'move' ) { eei . emit ( e , payload ) ; } else if ( e === 'done' ) { eei . emit ( e ) ; return '1' ; } throw 'unknown event' ; } ; broadcast ( 'stop' ) ; broadcast ( 'moveRequest' , { x : 1 , y : 2 } ) ; interface CustomEE { on ( e , cb ) : void ; } let cee = { on : ( ) => undefined } ; let val = cee . on ( 'move' , pos => { } ) ; type MyEmitter = StrictEventEmitter < EventEmitter , Events > ; class MyEventEmitter extends ( EventEmitter as { new ( ) : MyEmitter ; } ) { doEmit ( ) { this . emit ( 'move' , { x : 1 , y : 2 } ) ; } }