@@ -99,46 +99,49 @@ declare namespace Pako {
9999
100100 type Data = Uint8Array | ArrayBuffer ;
101101
102+ // For TS <=5.6 compatibility: Uint8Array<ArrayBuffer> in TS >=5.7, Uint8Array in TS <=5.6
103+ type Uint8ArrayReturnType = InstanceType < typeof Uint8Array > ;
104+
102105 /**
103106 * Compress data with deflate algorithm and options.
104107 */
105- function deflate ( data : Data | string , options ?: DeflateFunctionOptions ) : Uint8Array ;
108+ function deflate ( data : Data | string , options ?: DeflateFunctionOptions ) : Uint8ArrayReturnType ;
106109
107110 /**
108111 * The same as deflate, but creates raw data, without wrapper (header and adler32 crc).
109112 */
110- function deflateRaw ( data : Data | string , options ?: DeflateFunctionOptions ) : Uint8Array ;
113+ function deflateRaw ( data : Data | string , options ?: DeflateFunctionOptions ) : Uint8ArrayReturnType ;
111114
112115 /**
113116 * The same as deflate, but create gzip wrapper instead of deflate one.
114117 */
115- function gzip ( data : Data | string , options ?: DeflateFunctionOptions ) : Uint8Array ;
118+ function gzip ( data : Data | string , options ?: DeflateFunctionOptions ) : Uint8ArrayReturnType ;
116119
117120 /**
118121 * Decompress data with inflate/ungzip and options. Autodetect format via wrapper header
119122 * by default. That's why we don't provide separate ungzip method.
120123 */
121124 function inflate ( data : Data , options : InflateFunctionOptions & { to : "string" } ) : string ;
122- function inflate ( data : Data , options ?: InflateFunctionOptions ) : Uint8Array ;
125+ function inflate ( data : Data , options ?: InflateFunctionOptions ) : Uint8ArrayReturnType ;
123126
124127 /**
125128 * The same as inflate, but creates raw data, without wrapper (header and adler32 crc).
126129 */
127130 function inflateRaw ( data : Data , options : InflateFunctionOptions & { to : "string" } ) : string ;
128- function inflateRaw ( data : Data , options ?: InflateFunctionOptions ) : Uint8Array ;
131+ function inflateRaw ( data : Data , options ?: InflateFunctionOptions ) : Uint8ArrayReturnType ;
129132
130133 /**
131134 * Just shortcut to inflate, because it autodetects format by header.content. Done for convenience.
132135 */
133136 function ungzip ( data : Data , options : InflateFunctionOptions & { to : "string" } ) : string ;
134- function ungzip ( data : Data , options ?: InflateFunctionOptions ) : Uint8Array ;
137+ function ungzip ( data : Data , options ?: InflateFunctionOptions ) : Uint8ArrayReturnType ;
135138
136139 // https://github.com/nodeca/pako/blob/893381abcafa10fa2081ce60dae7d4d8e873a658/lib/deflate.js
137140 class Deflate {
138141 constructor ( options ?: DeflateOptions ) ;
139142 err : ReturnCodes ;
140143 msg : string ;
141- result : Uint8Array ;
144+ result : Uint8ArrayReturnType ;
142145 onData ( chunk : Data ) : void ;
143146 onEnd ( status : number ) : void ;
144147 push ( data : Data | string , mode ?: FlushValues | boolean ) : boolean ;
@@ -150,7 +153,7 @@ declare namespace Pako {
150153 header ?: Header | undefined ;
151154 err : ReturnCodes ;
152155 msg : string ;
153- result : Uint8Array | string ;
156+ result : Uint8ArrayReturnType | string ;
154157 onData ( chunk : Data ) : void ;
155158 onEnd ( status : number ) : void ;
156159 push ( data : Data , mode ?: FlushValues | boolean ) : boolean ;
0 commit comments