Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add ref() and unref() to chokidar.d.ts for typescript build to work. #15706

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/vite/src/node/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ class NoopWatcher extends EventEmitter implements FSWatcher {
return {}
}

ref() {
return this
}

unref() {
return this
}

async close() {
// noop
}
Expand Down
13 changes: 13 additions & 0 deletions packages/vite/src/types/chokidar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ export class FSWatcher extends EventEmitter implements fs.FSWatcher {
*/
constructor(options?: WatchOptions)

/**
* When called, requests that the Node.js event loop not exit so long as the fs.FSWatcher is active.
* Calling watcher.ref() multiple times will have no effect.
*/
ref(): this

/**
* When called, the active fs.FSWatcher object will not require the Node.js event loop to remain active.
* If there is no other activity keeping the event loop running, the process may exit before the fs.FSWatcher object's callback is invoked.
* Calling watcher.unref() multiple times will have no effect.
*/
unref(): this

/**
* Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
* string.
Expand Down