@@ -53,21 +53,29 @@ export type BasePluginOptions<T> = {
53
53
test ?: Rules | undefined ;
54
54
include ?: Rules | undefined ;
55
55
exclude ?: Rules | undefined ;
56
- algorithm ?: string | AlgorithmFunction < T > | undefined ;
57
- compressionOptions ?: InferDefaultType < T > | undefined ;
58
56
threshold ?: number | undefined ;
59
57
minRatio ?: number | undefined ;
60
58
deleteOriginalAssets ?: DeleteOriginalAssets | undefined ;
61
59
filename ?: Filename | undefined ;
62
60
} ;
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
+ } ;
63
71
export type InternalPluginOptions < T > = BasePluginOptions < T > & {
72
+ algorithm : string | AlgorithmFunction < T > ;
64
73
compressionOptions : CompressionOptions < T > ;
65
74
threshold : number ;
66
75
minRatio : number ;
67
76
deleteOriginalAssets : DeleteOriginalAssets ;
68
77
filename : Filename ;
69
78
} ;
70
- export type ZlibOptions = import ( "zlib" ) . ZlibOptions ;
71
79
/** @typedef {import("schema-utils/declarations/validate").Schema } Schema */
72
80
/** @typedef {import("webpack").Compiler } Compiler */
73
81
/** @typedef {import("webpack").WebpackPluginInstance } WebpackPluginInstance */
@@ -114,19 +122,21 @@ export type ZlibOptions = import("zlib").ZlibOptions;
114
122
* @property {Rules } [test]
115
123
* @property {Rules } [include]
116
124
* @property {Rules } [exclude]
117
- * @property {string | AlgorithmFunction<T> } [algorithm]
118
- * @property {CompressionOptions<T> } [compressionOptions]
119
125
* @property {number } [threshold]
120
126
* @property {number } [minRatio]
121
127
* @property {DeleteOriginalAssets } [deleteOriginalAssets]
122
128
* @property {Filename } [filename]
123
129
*/
130
+ /**
131
+ * @typedef {import("zlib").ZlibOptions } ZlibOptions
132
+ */
124
133
/**
125
134
* @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
127
136
*/
128
137
/**
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
130
140
*/
131
141
/**
132
142
* @template [T=ZlibOptions]
@@ -136,9 +146,13 @@ declare class CompressionPlugin<T = import("zlib").ZlibOptions>
136
146
implements WebpackPluginInstance
137
147
{
138
148
/**
139
- * @param {BasePluginOptions<T> } [options]
149
+ * @param {BasePluginOptions<T> & DefinedDefaultAlgorithmAndOptions<T> } [options]
140
150
*/
141
- constructor ( options ?: BasePluginOptions < T > | undefined ) ;
151
+ constructor (
152
+ options ?:
153
+ | ( BasePluginOptions < T > & DefinedDefaultAlgorithmAndOptions < T > )
154
+ | undefined
155
+ ) ;
142
156
/**
143
157
* @private
144
158
* @type {InternalPluginOptions<T> }
0 commit comments