paulmillr / chokidar

Minimal and efficient cross-platform file watching library
https://paulmillr.com
MIT License
11.04k stars 586 forks source link

v4: types and jsdoc do not align #1355

Closed benmccann closed 2 months ago

benmccann commented 2 months ago

Describe the bug

The index.d.ts file has:

    /**
     * Close watchers and remove all listeners from watched paths.
     * @returns {Promise<void>}.
     */
    close(): Promise<void> | undefined;

Versions (please complete the following information):

To Reproduce:

Open index.d.ts

Expected behavior

Types and docs should match

Additional context

This prevents wrangler from upgrading because it expects a Promise<void> to be returned:

src/dev/use-esbuild.ts(226,4): error TS2322: Type '() => Promise<void> | undefined' is not assignable to type '() => Promise<void>'.
43081j commented 2 months ago

I think it should be Promise<void>

It may be worth annotating the return type in the source so we're certain it's always a promise (i.e to catch where we forgot to return one)