-
-
Notifications
You must be signed in to change notification settings - Fork 109
Closed
Description
Bug report
Type definition BasePluginOptions
has the wrong type definition Rule
for properties test
, include
and exclude
.
/** @typedef {RegExp | string} Rule */
/** @typedef {Rule[] | Rule} Rules */
/**
* @template T
* @typedef {Object} BasePluginOptions
* @property {Rule} [test]
* @property {Rule} [include]
* @property {Rule} [exclude]
* ...
*/
According to the documentation
type test = string | RegExp | Array<string | RegExp>;
the properties should be defined as Rules
:
/**
* @template T
* @typedef {Object} BasePluginOptions
* @property {Rules} [test]
* @property {Rules} [include]
* @property {Rules} [exclude]
* ...
*/
Actual Behavior
When passing array of RegExp as test
property in CompressionPlugin
constructor, TypeScript will be unable to compile when running Webpack script with TypeScript:
error TS2322: Type 'RegExp[]' is not assignable to type 'Rule'
Expected Behavior
Expect no TypeScript errors when running Webpack script with TypeScript.
How Do We Reproduce?
// my-script.ts
const compressionPlugin = new CompressionPlugin({
test: [ /foo/, /bar/ ],
});
ts-node my-script.ts
Please paste the results of npx webpack-cli info
here, and mention other relevant information
System:
OS: macOS 13.6.3
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 6.69 GB / 32.00 GB
Binaries:
Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
Browsers:
Chrome: 121.0.6167.184
Safari: 16.6
"compression-webpack-plugin": "^11.0.0",
"webpack": "^5.90.3",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
Metadata
Metadata
Assignees
Labels
No labels