Klathmon / imagemin-webpack-plugin

Plugin to compress images with imagemin
MIT License
683 stars 53 forks source link

@types/webpack throwing type errors in Webpack v5 #119

Open jljorgenson18 opened 3 years ago

jljorgenson18 commented 3 years ago

imagemin-webpack-plugin has a dependency on @types/webpack v4. However, v4 imports tapable which in recent versions will break with webpack v4. This means that if you upgrade to Webpack v5 which will upgrade tapable internally, you end up with type errors coming from imagemin-webpack-plugin (unless skipLibCheck is set to true)

node_modules/imagemin-webpack-plugin/node_modules/@types/webpack/index.d.ts:32:3 - error TS2305: Module '"tapable"' has no exported member 'Tapable'.

32   Tapable,
     ~~~~~~~

node_modules/imagemin-webpack-plugin/node_modules/@types/webpack/index.d.ts:1062:23 - error TS2707: Generic type 'SyncWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1062             resolver: SyncWaterfallHook;
                           ~~~~~~~~~~~~~~~~~

node_modules/imagemin-webpack-plugin/node_modules/@types/webpack/index.d.ts:1063:22 - error TS2707: Generic type 'SyncWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1063             factory: SyncWaterfallHook;
                          ~~~~~~~~~~~~~~~~~

node_modules/imagemin-webpack-plugin/node_modules/@types/webpack/index.d.ts:1064:28 - error TS2707: Generic type 'AsyncSeriesWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1064             beforeResolve: AsyncSeriesWaterfallHook;
                                ~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/imagemin-webpack-plugin/node_modules/@types/webpack/index.d.ts:1065:27 - error TS2707: Generic type 'AsyncSeriesWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1065             afterResolve: AsyncSeriesWaterfallHook;
                               ~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/imagemin-webpack-plugin/node_modules/@types/webpack/index.d.ts:1066:27 - error TS2707: Generic type 'SyncBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1066             createModule: SyncBailHook;
                               ~~~~~~~~~~~~

And so on. I'm not positive what the right answer is here but maybe making @types/webpack a peerDependency or using * instead of v4 may fix it.