@@ -53,21 +53,29 @@ export type BasePluginOptions<T> = {
5353 test ?: Rules | undefined ;
5454 include ?: Rules | undefined ;
5555 exclude ?: Rules | undefined ;
56- algorithm ?: string | AlgorithmFunction < T > | undefined ;
57- compressionOptions ?: InferDefaultType < T > | undefined ;
5856 threshold ?: number | undefined ;
5957 minRatio ?: number | undefined ;
6058 deleteOriginalAssets ?: DeleteOriginalAssets | undefined ;
6159 filename ?: Filename | undefined ;
6260} ;
61+ export type ZlibOptions = import ( "zlib" ) . ZlibOptions ;
62+ export type DefinedDefaultAlgorithmAndOptions < T > = T extends ZlibOptions
63+ ? {
64+ algorithm ?: string | AlgorithmFunction < T > | undefined ;
65+ compressionOptions ?: CompressionOptions < T > | undefined ;
66+ }
67+ : {
68+ algorithm : string | AlgorithmFunction < T > ;
69+ compressionOptions ?: CompressionOptions < T > | undefined ;
70+ } ;
6371export type InternalPluginOptions < T > = BasePluginOptions < T > & {
72+ algorithm : string | AlgorithmFunction < T > ;
6473 compressionOptions : CompressionOptions < T > ;
6574 threshold : number ;
6675 minRatio : number ;
6776 deleteOriginalAssets : DeleteOriginalAssets ;
6877 filename : Filename ;
6978} ;
70- export type ZlibOptions = import ( "zlib" ) . ZlibOptions ;
7179/** @typedef {import("schema-utils/declarations/validate").Schema } Schema */
7280/** @typedef {import("webpack").Compiler } Compiler */
7381/** @typedef {import("webpack").WebpackPluginInstance } WebpackPluginInstance */
@@ -114,19 +122,21 @@ export type ZlibOptions = import("zlib").ZlibOptions;
114122 * @property {Rules } [test]
115123 * @property {Rules } [include]
116124 * @property {Rules } [exclude]
117- * @property {string | AlgorithmFunction<T> } [algorithm]
118- * @property {CompressionOptions<T> } [compressionOptions]
119125 * @property {number } [threshold]
120126 * @property {number } [minRatio]
121127 * @property {DeleteOriginalAssets } [deleteOriginalAssets]
122128 * @property {Filename } [filename]
123129 */
130+ /**
131+ * @typedef {import("zlib").ZlibOptions } ZlibOptions
132+ */
124133/**
125134 * @template T
126- * @typedef {BasePluginOptions <T> & { compressionOptions: CompressionOptions<T>, threshold: number, minRatio: number, deleteOriginalAssets: DeleteOriginalAssets, filename: Filename } } InternalPluginOptions
135+ * @typedef {T extends ZlibOptions ? { algorithm?: string | AlgorithmFunction <T> | undefined, compressionOptions? : CompressionOptions<T> | undefined } : { algorithm: string | AlgorithmFunction<T>, compressionOptions?: CompressionOptions<T> | undefined } } DefinedDefaultAlgorithmAndOptions
127136 */
128137/**
129- * @typedef {import("zlib").ZlibOptions } ZlibOptions
138+ * @template T
139+ * @typedef {BasePluginOptions<T> & { algorithm: string | AlgorithmFunction<T>, compressionOptions: CompressionOptions<T>, threshold: number, minRatio: number, deleteOriginalAssets: DeleteOriginalAssets, filename: Filename } } InternalPluginOptions
130140 */
131141/**
132142 * @template [T=ZlibOptions]
@@ -136,9 +146,13 @@ declare class CompressionPlugin<T = import("zlib").ZlibOptions>
136146 implements WebpackPluginInstance
137147{
138148 /**
139- * @param {BasePluginOptions<T> } [options]
149+ * @param {BasePluginOptions<T> & DefinedDefaultAlgorithmAndOptions<T> } [options]
140150 */
141- constructor ( options ?: BasePluginOptions < T > | undefined ) ;
151+ constructor (
152+ options ?:
153+ | ( BasePluginOptions < T > & DefinedDefaultAlgorithmAndOptions < T > )
154+ | undefined
155+ ) ;
142156 /**
143157 * @private
144158 * @type {InternalPluginOptions<T> }
0 commit comments