Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types are broken with Webpack 5 #401

Open
dopry opened this issue Mar 17, 2021 · 4 comments
Open

Types are broken with Webpack 5 #401

dopry opened this issue Mar 17, 2021 · 4 comments

Comments

@dopry
Copy link

dopry commented Mar 17, 2021

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

@glenjamin
Copy link
Collaborator

glenjamin commented Mar 17, 2021 via email

@BTOdell
Copy link

BTOdell commented Jun 2, 2021

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.

@ITenthusiasm
Copy link

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. 🙂)

@ch3ll0v3k
Copy link

i had same issue. it was caused by this params.
commenting it out removed all errors

and now i can use TS with webpack

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants