Skip to content

Commit 6b45037

Browse files
authored
fix: add ref() and unref() to chokidar.d.ts for typescript build to work (#15706)
1 parent 2805b2d commit 6b45037

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/vite/src/node/watch.ts

+8
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ class NoopWatcher extends EventEmitter implements FSWatcher {
4545
return {}
4646
}
4747

48+
ref() {
49+
return this
50+
}
51+
52+
unref() {
53+
return this
54+
}
55+
4856
async close() {
4957
// noop
5058
}

packages/vite/src/types/chokidar.d.ts

+13
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ export class FSWatcher extends EventEmitter implements fs.FSWatcher {
4040
*/
4141
constructor(options?: WatchOptions)
4242

43+
/**
44+
* When called, requests that the Node.js event loop not exit so long as the fs.FSWatcher is active.
45+
* Calling watcher.ref() multiple times will have no effect.
46+
*/
47+
ref(): this
48+
49+
/**
50+
* When called, the active fs.FSWatcher object will not require the Node.js event loop to remain active.
51+
* If there is no other activity keeping the event loop running, the process may exit before the fs.FSWatcher object's callback is invoked.
52+
* Calling watcher.unref() multiple times will have no effect.
53+
*/
54+
unref(): this
55+
4356
/**
4457
* Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
4558
* string.

0 commit comments

Comments
 (0)