2
2
export default CompressionPlugin ;
3
3
export type Schema = import ( "schema-utils/declarations/validate" ) . Schema ;
4
4
export type Compiler = import ( "webpack" ) . Compiler ;
5
+ export type WebpackPluginInstance = import ( "webpack" ) . WebpackPluginInstance ;
5
6
export type Compilation = import ( "webpack" ) . Compilation ;
6
7
export type Source = import ( "webpack" ) . sources . Source ;
7
8
export type Asset = import ( "webpack" ) . Asset ;
8
9
export type WebpackError = import ( "webpack" ) . WebpackError ;
10
+ export type WithImplicitCoercion < T > =
11
+ | T
12
+ | {
13
+ valueOf ( ) : T ;
14
+ } ;
9
15
export type Rule = RegExp | string ;
10
16
export type Rules = Rule [ ] | Rule ;
11
17
export type CustomOptions = {
@@ -16,7 +22,27 @@ export type CompressionOptions<T> = InferDefaultType<T>;
16
22
export type AlgorithmFunction < T > = (
17
23
input : Buffer ,
18
24
options : CompressionOptions < T > ,
19
- callback : ( error : Error , result : string | Buffer ) => void
25
+ callback : (
26
+ error : Error | null | undefined ,
27
+ result :
28
+ | string
29
+ | ArrayBuffer
30
+ | SharedArrayBuffer
31
+ | Uint8Array
32
+ | readonly number [ ]
33
+ | {
34
+ valueOf ( ) : ArrayBuffer | SharedArrayBuffer ;
35
+ }
36
+ | {
37
+ valueOf ( ) : string | Uint8Array | readonly number [ ] ;
38
+ }
39
+ | {
40
+ valueOf ( ) : string ;
41
+ }
42
+ | {
43
+ [ Symbol . toPrimitive ] ( hint : "string" ) : string ;
44
+ }
45
+ ) => void
20
46
) => any ;
21
47
export type PathData = {
22
48
[ key : string ] : any ;
@@ -44,10 +70,15 @@ export type InternalPluginOptions<T> = BasePluginOptions<T> & {
44
70
export type ZlibOptions = import ( "zlib" ) . ZlibOptions ;
45
71
/** @typedef {import("schema-utils/declarations/validate").Schema } Schema */
46
72
/** @typedef {import("webpack").Compiler } Compiler */
73
+ /** @typedef {import("webpack").WebpackPluginInstance } WebpackPluginInstance */
47
74
/** @typedef {import("webpack").Compilation } Compilation */
48
75
/** @typedef {import("webpack").sources.Source } Source */
49
76
/** @typedef {import("webpack").Asset } Asset */
50
77
/** @typedef {import("webpack").WebpackError } WebpackError */
78
+ /**
79
+ * @template T
80
+ * @typedef {T | { valueOf(): T } } WithImplicitCoercion
81
+ */
51
82
/** @typedef {RegExp | string } Rule */
52
83
/** @typedef {Rule[] | Rule } Rules */
53
84
/**
@@ -66,7 +97,7 @@ export type ZlibOptions = import("zlib").ZlibOptions;
66
97
* @callback AlgorithmFunction
67
98
* @param {Buffer } input
68
99
* @param {CompressionOptions<T> } options
69
- * @param {(error: Error, result: string | Buffer ) => void } callback
100
+ * @param {(error: Error | null | undefined , result: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer> | Uint8Array | ReadonlyArray<number> | WithImplicitCoercion<Uint8Array | ReadonlyArray<number> | string> | WithImplicitCoercion<string> | { [Symbol.toPrimitive](hint: 'string'): string } ) => void } callback
70
101
*/
71
102
/**
72
103
* @typedef {{[key: string]: any} } PathData
@@ -99,8 +130,11 @@ export type ZlibOptions = import("zlib").ZlibOptions;
99
130
*/
100
131
/**
101
132
* @template [T=ZlibOptions]
133
+ * @implements WebpackPluginInstance
102
134
*/
103
- declare class CompressionPlugin < T = import ( "zlib" ) . ZlibOptions > {
135
+ declare class CompressionPlugin < T = import ( "zlib" ) . ZlibOptions >
136
+ implements WebpackPluginInstance
137
+ {
104
138
/**
105
139
* @param {BasePluginOptions<T> } [options]
106
140
*/
0 commit comments