Skip to content

Commit

Permalink
fix: add ref() and unref() to chokidar.d.ts for typescript build to w…
Browse files Browse the repository at this point in the history
…ork (#15706)
  • Loading branch information
saerich authored Jan 29, 2024
1 parent 2805b2d commit 6b45037
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
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

0 comments on commit 6b45037

Please sign in to comment.