@@ -60,8 +60,9 @@ export type FSWInstanceOptions = BasicOpts & {
60
60
} ;
61
61
62
62
export type ThrottleType = 'readdir' | 'watch' | 'add' | 'remove' | 'change' ;
63
- export type EmitArgs = [ Path | Error , Stats ?] ;
64
- export type EmitArgsWithName = [ EventName , ...EmitArgs ] ;
63
+ export type EmitArgs = [ path : Path , stats ?: Stats ] ;
64
+ export type EmitErrorArgs = [ error : Error , stats ?: Stats ] ;
65
+ export type EmitArgsWithName = [ event : EventName , ...EmitArgs ] ;
65
66
export type MatchFunction = ( val : string , stats ?: Stats ) => boolean ;
66
67
export interface MatcherObject {
67
68
path : string ;
@@ -302,7 +303,7 @@ export interface FSWatcherKnownEventMap {
302
303
[ EV . READY ] : [ ] ;
303
304
[ EV . RAW ] : Parameters < WatchHandlers [ 'rawEmitter' ] > ;
304
305
[ EV . ERROR ] : Parameters < WatchHandlers [ 'errHandler' ] > ;
305
- [ EV . ALL ] : [ EventName , ...EmitArgs ] ;
306
+ [ EV . ALL ] : [ event : EventName , ...EmitArgs ] ;
306
307
}
307
308
308
309
export type FSWatcherEventMap = FSWatcherKnownEventMap & {
@@ -602,7 +603,7 @@ export class FSWatcher extends EventEmitter<FSWatcherEventMap> {
602
603
const opts = this . options ;
603
604
if ( isWindows ) path = sysPath . normalize ( path ) ;
604
605
if ( opts . cwd ) path = sysPath . relative ( opts . cwd , path ) ;
605
- const args : EmitArgs = [ path ] ;
606
+ const args : EmitArgs | EmitErrorArgs = [ path ] ;
606
607
if ( stats != null ) args . push ( stats ) ;
607
608
608
609
const awf = opts . awaitWriteFinish ;
@@ -637,7 +638,7 @@ export class FSWatcher extends EventEmitter<FSWatcherEventMap> {
637
638
const awfEmit = ( err ?: Error , stats ?: Stats ) => {
638
639
if ( err ) {
639
640
event = EV . ERROR ;
640
- args [ 0 ] = err ;
641
+ ( args as unknown as EmitErrorArgs ) [ 0 ] = err ;
641
642
this . emitWithAll ( event , args ) ;
642
643
} else if ( stats ) {
643
644
// if stats doesn't exist the file must have been deleted
0 commit comments