In v3 close() returned Promise<void>. https://github.com/paulmillr/chokidar/pull/1356 was just merged which turns it to Promise<void> | undefined, but this doesn't feel like the correct solution to me. The only way it can return undefined is if the user does watcher.closed = true followed by watcher.close().
Expected behavior
I don't think the user should be able to directly set watcher.closed as it skips all of the other cleanup. It also makes migration from v3 to v4 more difficult by changing the type signature of close()
Describe the bug
In v3
close()
returnedPromise<void>
. https://github.com/paulmillr/chokidar/pull/1356 was just merged which turns it toPromise<void> | undefined
, but this doesn't feel like the correct solution to me. The only way it can returnundefined
is if the user doeswatcher.closed = true
followed bywatcher.close()
.Expected behavior
I don't think the user should be able to directly set
watcher.closed
as it skips all of the other cleanup. It also makes migration from v3 to v4 more difficult by changing the type signature ofclose()
Additional context
See https://github.com/paulmillr/chokidar/pull/1356 and the issue it closed https://github.com/paulmillr/chokidar/issues/1355 for more details. There was an unresolved question about this on the PR https://github.com/paulmillr/chokidar/pull/1356#discussion_r1765000077, but unfortunately I didn't have a chance to chime in.