Typescript types are not correct
awdr74100 opened this issue · 0 comments
awdr74100 commented
Bug report
There seems to be a type error in the sharpMinify minimizer in a webpack.prod.conf.ts
configuration file I'm running.
Actual Behavior
The main code is copied from README.md
.
import { Configuration } from 'webpack';
import { merge } from 'webpack-merge';
import ImageMinimizerPlugin from 'image-minimizer-webpack-plugin';
import baseWebpackConfig from './webpack.base.conf';
const config = merge<Configuration>(baseWebpackConfig, {
mode: 'production',
devtool: 'source-map',
optimization: {
minimize: true,
minimizer: [
'...',
new ImageMinimizerPlugin({
minimizer: {
// Implementation
implementation: ImageMinimizerPlugin.sharpMinify,
// Options
options: {
encodeOptions: {
jpeg: {
quality: 90,
},
},
},
},
}),
],
},
});
export default config;
Type '{ implementation: (original: ImageMinimizerPlugin.WorkerResult, minimizerOptions?: SharpOptions | undefined) => Promise<ImageMinimizerPlugin.WorkerResult>; options: { ...; }; }' is not assignable to type 'Minimizer<unknown> | Minimizer<unknown>[] | undefined'.
Types of property 'implementation' are incompatible.
Type '(original: WorkerResult, minimizerOptions?: SharpOptions | undefined) => Promise<WorkerResult>' is not assignable to type 'TransformerFunction<unknown>'.
Type '(original: WorkerResult, minimizerOptions?: SharpOptions | undefined) => Promise<WorkerResult>' is not assignable to type 'BasicTransformerImplementation<unknown>'.
Types of parameters 'minimizerOptions' and 'options' are incompatible.
Type 'unknown' is not assignable to type 'SharpOptions | undefined'.
Expected Behavior
It should work as well as other minimizer.
How Do We Reproduce?
Write the sharpMinify minimizer example provided in README.md
through the webpack.config.ts
configuration file.
Please paste the results of npx webpack-cli info
here, and mention other relevant information
System:
OS: Windows 10 10.0.22000
CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
Memory: 5.38 GB / 15.92 GB
Binaries:
Node: 16.17.0 - ~\AppData\Local\fnm_multishells\952_1662275595539\node.EXE
Yarn: 1.22.19 - ~\AppData\Local\fnm_multishells\952_1662275595539\yarn.CMD
npm: 8.19.1 - ~\AppData\Local\fnm_multishells\952_1662275595539\npm.CMD
Browsers:
Edge: Spartan (44.22000.120.0), Chromium (104.0.1293.70)
Internet Explorer: 11.0.22000.120
Packages:
clean-webpack-plugin: ^4.0.0 => 4.0.0
css-loader: ^6.7.1 => 6.7.1
esbuild-loader: ^2.20.0 => 2.20.0
eslint-webpack-plugin: ^3.2.0 => 3.2.0
fork-ts-checker-webpack-plugin: ^7.2.13 => 7.2.13
html-webpack-plugin: ^5.5.0 => 5.5.0
image-minimizer-webpack-plugin: ^3.3.0 => 3.3.0
postcss-loader: ^7.0.1 => 7.0.1
style-loader: ^3.3.1 => 3.3.1
stylelint-webpack-plugin: ^3.3.0 => 3.3.0
tsconfig-paths-webpack-plugin: ^4.0.0 => 4.0.0
webpack: ^5.74.0 => 5.74.0
webpack-cli: ^4.10.0 => 4.10.0
webpack-dev-server: ^4.10.1 => 4.10.1
webpack-merge: ^5.8.0 => 5.8.0