Reputation: 104
My project has been using zlib for its decompression methods for a long time. Suddenly while trying to update packages its throwing a TypeError in the following code:
Argument of type 'Buffer' is not assignable to parameter of type 'InputType'.
Type 'Buffer' is not assignable to type 'ArrayBuffer | Uint8Array<ArrayBufferLike> | DataView<ArrayBufferLike>'.
Type 'Buffer' is not assignable to type 'Uint8Array<ArrayBufferLike>'.
The types of 'slice(...).buffer' are incompatible between these types.
Type 'ArrayBufferLike' is not assignable to type 'ArrayBuffer'.
Type 'SharedArrayBuffer' is missing the following properties from type 'ArrayBuffer': resizable, resize, detached, transfer, transferToFixedLength
import { deflateSync, gzipSync } from 'zlib'
const getFile = () => {
if (compression === 'gzip') {
return gzipSync(Buffer.from(csv)) // Here
} else if (compression === 'deflate') {
return deflateSync(Buffer.from(csv)) // Here
} else {
return Buffer.from(csv)
}
}
zlib is a core node.js module and in my package.json there is no indication of either node or this lib to have been upgraded. So I am unsure of why this TypeError is getting thrown now. zlib hasnt been updated recently. Doing the following fixes this issue:
gzipSync(new Uint8Array(Buffer.from(csv)))
Since the code is only used in tests and the tests still work, I am only interested in knowing the root cause. Why did this error suddenly appear when seemingly nothing changed?
Upvotes: 0
Views: 145