Closed devversion closed 7 months ago
There is a possible quick fix - change this line https://github.com/paulmillr/chokidar/blob/5589454f3e082c5c476de11277346ee3debe5ad4/types/index.d.ts#L9 to
export class FSWatcher extends EventEmitter implements Omit<fs.FSWatcher, 'ref' | 'unref'> {
Or define these missed methods.
so why was it fine before? maybe it’s not ours issue?
I don't have enough context unfortunately, but at first glance it looks like:
fs.FSWatcher
actually defines these two methods always
@types/node
, and users will see those. chokidar
"implements" fs.FSWatcher
but with the new interface, it does not fully implement the latest version of fs.FSWatcher
.
FSWatcher
.ref
and unref
were added in v14.3.0, v12.20.0 to Node.js but were missed in @types/node
.
For those that may come here later... when working with Capacitor their @capacitor-community/electron module (which sets up electron for Capacitor) the 'npm run build' will fail for capacitor as it uses chokidar in setup.ts.
You have been warned :) Work around until this is resolved is 'npm install @types/node@16.18.71' within your electron directory.
same issue when working with @types/node@18.19.9
and newer
I wasn't successful with the Omit<fs.FSWatcher, "ref" | "unref">
solution has methods returning this
would not be compatible anymore.
Instead for now I'm going with this solution. Something looks off so I'm not sure enough to make a PR on this repo, but at least it unblocks me
export class FSWatcher extends EventEmitter implements fs.FSWatcher {
ref(): never;
unref(): never;
}
published 3.6.0
Versions (please complete the following information):
To Reproduce:
@types/node
in this repository to e.g. latest Node v16 types: 16.18.75types/index.d.ts
is not properly extendingfs.FSWatcher
Expected behavior Chokidar types should work with most recent versions of
@types/node
. TypeScript projects will face similar errors when building withskipLibCheck: false
(which is the default)Additional context
Change in
@types/node
that made this breaking change (to match Node versions) in a SemVer patch: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/68300