Skip to content

feat: convert Watcher class declaration to interfaces - #33

Closed
mrazauskas wants to merge 1 commit into
platformatic:mainfrom
mrazauskas:class-to-interface
Closed

feat: convert Watcher class declaration to interfaces#33
mrazauskas wants to merge 1 commit into
platformatic:mainfrom
mrazauskas:class-to-interface

Conversation

@mrazauskas

@mrazauskas mrazauskas commented May 28, 2026

Copy link
Copy Markdown

Alternative to #32

This PR converts the Watcher class declaration to interfaces.

As explained in #32, currently TypeScript reports declarations of addListener() and removeListener() as incompatible with the original class (see #31). When a class is converted into an interface, it is possible to use Omit<EventEmitter, 'addListener' | 'removeListener'>. This solves the problem.

The only difference for a user is that it will not be possible to use new on VFSStatWatcher and other classes. These classes are not exported from index.js. The type declaration model the return types of watch(), watchFile(), and watchAsync(). So that shouldn’t be a problem.

I suggest converting all three classes so that the return typings of all three watch methods are consistently modelled using interfaces.


Close #32

Signed-off-by: mrazauskas <tom@mrazauskas.de>
@mrazauskas

Copy link
Copy Markdown
Author

Might be this isn’t useful since node:vfs was introduced.

@mrazauskas mrazauskas closed this Aug 20, 2026
@mrazauskas
mrazauskas deleted the class-to-interface branch August 20, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant