Skip to content

Commit

Permalink
add typing to event listeners (#811)
Browse files Browse the repository at this point in the history
  • Loading branch information
hKaspy authored and paulmillr committed Mar 22, 2019
1 parent 1ea6388 commit 4954842
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions types/index.d.ts
Expand Up @@ -43,6 +43,29 @@ export class FSWatcher extends EventEmitter implements fs.FSWatcher {
* Removes all listeners from watched files.
*/
close(): void;

on(event: 'add'|'addDir'|'change', listener: (path: string, stats?: fs.Stats) => void): this;

on(event: 'all', listener: (eventName: 'add'|'addDir'|'change'|'unlink'|'unlinkDir', path: string, stats?: fs.Stats) => void): this;

/**
* Error occured
*/
on(event: 'error', listener: (error: Error) => void): this;

/**
* Exposes the native Node `fs.FSWatcher events`
*/
on(event: 'raw', listener: (eventName: string, path: string, details: any) => void): this;

/**
* Fires when the initial scan is complete
*/
on(event: 'ready', listener: () => void): this;

on(event: 'unlink'|'unlinkDir', listener: (path: string) => void): this;

on(event: string, listener: (...args: any[]) => void): this;
}

export interface WatchOptions {
Expand Down

0 comments on commit 4954842

Please sign in to comment.