webpack-hot-middleware icon indicating copy to clipboard operation
webpack-hot-middleware copied to clipboard

Types are broken with Webpack 5

Open dopry opened this issue 4 years ago • 3 comments

For those of us using typescript we are running into issued with @types/webpack, @types/webpack-dev-middleware published by DefinitelyTyped. It would be nice if this packaged included it's own types so we didn't need to depend on definitely typed..

see: DefinitelyTyped/DefinitelyTyped#49755 for context

dopry avatar Mar 17 '21 01:03 dopry

I would accept a PR which adds a .d.ts file for this project

On 17 Mar 2021, at 01:23, dopry @.***> wrote:

 For those of us using typescript we are running into issued with @types/webpack, @types/webpack-dev-middleware published by DefinitelyTyped. It would be nice if this packaged included it's own types so we didn't need to depend on definitely typed..

see: DefinitelyTyped/DefinitelyTyped#49755 for context

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

glenjamin avatar Mar 17 '21 08:03 glenjamin

Webpack 5 has its own types now. If you remove your local dependency on @types/webpack, then the existing @types/webpack-hot-middleware will work again.

BTOdell avatar Jun 02 '21 06:06 BTOdell

Webpack 5 has its own types now. If you remove your local dependency on @types/webpack, then the existing @types/webpack-hot-middleware will work again.

Huge thanks to @BTOdell because it helped me discover another problem.

Just in case anyone else is running into TS error headaches and the above solution does not work, double-check for node_modules shenanigans. I was starting a new project and originally installed @types/webpack before I learned that webpack5 had their own type definitions. I later uninstalled @types/webpack, but I was still having TS errors when calling webpackDevMiddleware(webpackCompiler).

I found out that somewhere along the way, I ended up with node_modules/@types/webpack-dev-middlware/node_modules/webpack or something like that. Clearing node_modules and reinstalling didn't work. So I had to remove package-lock.json and node_modules... then reinstall.

(Someone super skilled and not as degenerate as myself probably could've corrected package-lock.json directly instead of recreating it. But since I was working with a new project, a full reset didn't really matter for me. 🙂)

ITenthusiasm avatar Jun 14 '21 16:06 ITenthusiasm