Skip to content

feat: convert Watcher class declaration to interfaces#33

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

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

Conversation

@mrazauskas
Copy link
Copy Markdown

@mrazauskas mrazauskas commented May 28, 2026

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>
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