-
Notifications
You must be signed in to change notification settings - Fork 136
Move @types/webpack to dependencies rather than devDependencies #127
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
Comments
The reason is because you should be installing Please provide a use case that you would install |
I'm not writing my webpack configs in TypeScript, so I don't see the reason why I should mandatorily add it as a dependency of my project. |
You most likely are using the |
Moved |
This change can actually break the build for web projects, as @types/node are now pulled into the scope causing jquery bindings to break among others. |
@Sebazzz please provide a repository showing this and/or link showing why/when this could happen. |
I don't have a minimal repo yet, but you can check out this project and update the clean-webpack-plugin package (yarn). The additional typings will now be taken into consideration for compilation. |
I don't see how this will break any projects. Mine is also a Web project and it worked fine. Can you at least send the jQuery errors that were thrown? |
This is definitely causing a problem, but am unsure what to do to fix it. @types/webpack-env fixes some of the problems. I think we probably need to remove the Thoughts? |
What's the error that's happening? If someone is experimenting an error because it's now installed automatically, they will keep facing it if you remove and then they install it manually (on a project that uses TypeScript). It's better to understand and try to fix the error (if it's possible) rather than shallowing it. |
I agree, but I think it has to be solved on a project by project basis. The issue seems that
Again, I agree. But I also don't think pulling in this library should cause additional typescript errors otherwise not present. If anyone knows someone that is well-versed in Webpack with Typescript that we can get in this thread it would be great. With the example provided by @Sebazzz: Without js/App/App.ts:14:16 - error TS2339: Property 'hot' does not exist on type 'NodeModule'.
14 if (module.hot) {
~~~
js/App/App.ts:15:16 - error TS2339: Property 'hot' does not exist on type 'NodeModule'.
15 module.hot.accept('./BindingHandlers/All', () => {
~~~
js/App/Navigation.ts:8:16 - error TS2339: Property 'hot' does not exist on type 'NodeModule'.
8 if (module.hot) {
~~~
js/App/Navigation.ts:9:16 - error TS2339: Property 'hot' does not exist on type 'NodeModule'.
9 module.hot.accept('App/Pages', () => {
~~~
js/AppFramework/AppFactory.ts:223:16 - error TS2339: Property 'hot' does not exist on type 'NodeModule'.
223 if (module.hot) {
~~~
js/AppFramework/AppFactory.ts:224:16 - error TS2339: Property 'hot' does not exist on type 'NodeModule'.
224 module.hot.accept('./BindingHandlers/All', () => {
~~~
js/AppFramework/Components/LoadingBar.ts:171:31 - error TS2558: Expected 0 type arguments, but got 1.
171 public template = require<string>('./templates/loading-bar.html');
~~~~~~
js/AppFramework/Components/Modal.ts:256:20 - error TS2339: Property 'hot' does not exist on type 'NodeModule'.
256 if (module.hot) {
~~~
js/AppFramework/Components/Modal.ts:257:20 - error TS2339: Property 'hot' does not exist on type 'NodeModule'.
257 module.hot.accept('./templates/modal.html', () => {
~~~
js/AppFramework/Components/Popover.ts:58:20 - error TS2339: Property 'hot' does not exist on type 'NodeModule'.
58 if (module.hot && !this.template) {
~~~
js/AppFramework/Components/Popover.ts:59:20 - error TS2339: Property 'hot' does not exist on type 'NodeModule'.
59 module.hot.accept('./templates/popover.html', () => {
~~~
js/AppFramework/Forms/Confirmation.ts:64:12 - error TS2339: Property 'hot' does not exist on type 'NodeModule'.
64 if (module.hot) {
~~~
js/AppFramework/Forms/Confirmation.ts:65:12 - error TS2339: Property 'hot' does not exist on type 'NodeModule'.
65 module.hot.accept('./templates/confirmation.html');
~~~ With js/AppFramework/ServerApi/HttpClient.ts:78:28 - error TS2345: Argument of type 'jqXHR<any>' is not assignable to parameter of type 'Promise<T>'.
Property 'finally' is missing in type 'jqXHR<any>' but required in type 'Promise<T>'.
78 requestHandler(promise);
~~~~~~~
node_modules/typescript/lib/lib.es2018.promise.d.ts:31:5
31 finally(onfinally?: (() => void) | undefined | null): Promise<T>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'finally' is declared here.
js/AppFramework/ServerApi/HttpClient.ts:81:9 - error TS2322: Type 'jqXHR<any>' is not assignable to type 'Promise<T>'.
81 return promise;
~~~~~~~~~~~~~~~ I am unsure how to solve the jQuery issues. |
The problem here is at his code. He's using jQuery Promises but he's declaring them as natives He should change those declarations here:
to use |
jQuery 3+ promises are actually compatible with ES promises, or at least, they were. You also may, for instance, await jquery promises. |
See: jquery/jquery#4290 So they've decided to not implement |
Thanks @rdsedmundo for tracking down the jquery issue! This still leaves us with the |
That seems like a logical solution. |
This is definitely a breaking change, and a big one. I have just updated clean-webpack-plugin to version 3, which caused @types/node being installed into node_modules, which in turn caused million of typescript errors in our angular/typescript project, because now we had two type declarations for setTimeout and other browser methods. The issue was really hard to investigate, as you wouldn't think that updating a plugin like this can cause these weird type errors across your project. And the only workaround available is downgrading plugin version back to 2.x |
@pshurygin Have you installed |
Just tried to install it, but it changes nothing. As it was mentioned in this thread, the issue is that @types/webpack, which is brought by v3, brings @types/node alongside self, which leads to errors in browsed-based typescript apps(conflicting type definitions between node and browser). Unless you remove it from dependencies, the issue would persist. To be clear, our webpack.config is native javascript, so we are not using @types/webpack or @types/webpack-env ourselves. Also we are not using allowJs option. |
I'd say to revert this if it's causing too many problems. I have the |
the 'webpack' package has its own declaration files, '@types/webpack' should not be used anymore, this has been the case for months if not years https://github.com/webpack/webpack/tree/master/declarations please consider removing '@types/webpack' package and depending on 'webpack' only |
Here's an example of a plugin I built in TS without @types/webpack: |
I get the error |
Try to remove |
I'm getting this error even though I'm not using typings on my Webpack configs at all, so it shouldn't be happening. I know I can just install the
@types/webpack
myself, but since the package is using it for something, it actually should be included as a dependency and installed automatically once I get the package.From TS docs:
The text was updated successfully, but these errors were encountered: