Skip to content

Commit

Permalink
Add flowtype for eventemitter3
Browse files Browse the repository at this point in the history
Reviewed By: cpojer

Differential Revision: D16459480

fbshipit-source-id: e560be242ef170e407f634638a9a581dbf5dc309
  • Loading branch information
gaearon authored and facebook-github-bot committed Jul 24, 2019
1 parent 2d590a6 commit 69afb2a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions flow-typed/eventemitter3.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// flow-typed signature: b7ab86e40fd87c2d7414d5ceb45ecddb
// flow-typed version: 6347e0da2b/eventemitter3_v3.x.x/flow_>=v0.25.x

declare module 'eventemitter3' {
declare type ListenerFn = (...args: any[]) => mixed
declare class EventEmitter {
static constructor(): EventEmitter,
static prefixed: string | boolean,
eventNames(): (string | Symbol)[],
listeners(event: string | Symbol): ListenerFn[],
listenerCount(event: string | Symbol): number,
on(event: string | Symbol, listener: ListenerFn, context?: any): this,
addListener(event: string | Symbol, listener: ListenerFn, context?: any): this,
once(event: string | Symbol, listener: ListenerFn, context?: any): this,
removeAllListeners(event?: string | Symbol): this,
removeListener(event: string | Symbol, listener?: ListenerFn, context?: any, once?: boolean): this,
off(event: string | Symbol, listener?: ListenerFn, context?: any, once?: boolean): this,
emit(event: string, ...params?: any[]): this
}
declare module.exports: Class<EventEmitter>
}

// Filename aliases
declare module 'eventemitter3/index' {
declare module.exports: $Exports<'eventemitter3'>
}
declare module 'eventemitter3/index.js' {
declare module.exports: $Exports<'eventemitter3'>
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/
'use strict';
Expand Down

0 comments on commit 69afb2a

Please sign in to comment.