paulmillr / chokidar

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

Type declarations are not extracted properly in published package #1392

Open rostislav-simonik opened 2 days ago

rostislav-simonik commented 2 days ago

Describe the bug

Depsite generic type in index.ts is declared properly

export class FSWatcher extends EventEmitter<FSWatcherEventMap> {

extracted types in index.ts (both esm, cjs) in a published package having the following declaration

export declare class FSWatcher extends EventEmitter {

ending up with any type inferred for event handlers

watch('src').on('all', (event, path) => { debounceSrc(path) })

// Unsafe argument of type `any` assigned to a parameter of type `string`.eslint[@typescript-eslint/no-unsafe-argument](https://typescript-eslint.io/rules/no-unsafe-argument)
(parameter) path: any

Versions (please complete the following information):

To Reproduce:

Self explanatory, but can provide it later if needed

Most valuable could be one or more test cases for test.js to demonstrate the problem.

Expected behavior The published package should have a type declaration with a generic type

export declare class FSWatcher extends EventEmitter<FSWatcherEventMap> {

Additional context Add any other context about the problem here. Optionally nice to know what project you are working on.

paulmillr commented 2 days ago

pull requests welcome

43081j commented 2 days ago

@paulmillr he's just too soon

the PR to add those strongly typed events hasn't been released yet

it is in main but we haven't published a new version of chokidar yet, so it won't be on npm

if you can publish a new version, that'd be helpful