-
Type: Bug
-
Resolution: Fixed
-
Priority: Critical - P2
-
Affects Version/s: 4.1.0
-
Component/s: TypeScript
-
Empty show more show less
-
Not Needed
What problem are you facing?
While upgrading drivers from 3.6.11 to 4.1.0 I get a TS compiling error that I can't resolve:
error TS2345: Argument of type 'GridFSBucketWriteStream' is not assignable to parameter of type 'WritableStream'. Types of property 'write' are incompatible. Type '{ (chunk: Buffer): boolean; (chunk: Buffer, callback: Callback<void>): boolean; (chunk: Buffer, encoding: BufferEncoding | undefined): boolean; (chunk: Buffer, encoding: BufferEncoding | undefined, callback: Callback<...>): boolean; }' is not assignable to type '{ (buffer: string | Uint8Array, cb?: ((err?: Error | null | undefined) => void) | undefined): boolean; (str: string, encoding?: BufferEncoding | undefined, cb?: ((err?: Error | ... 1 more ... | undefined) => void) | undefined): boolean; }'. Types of parameters 'chunk' and 'str' are incompatible. Type 'string' is not assignable to type 'Buffer'.95 .pipe(uploadStream)
With the previous version (3.6.11) the software compiles and runs smoothly
What driver and relevant dependency versions are you using?
I went from version 3.6.11 to 4.1.0
Steps to reproduce?
Try to build di TS code:
Text version:
import { Readable } from "stream";
import { GridFSBucket } from "mongodb";
export const storeDocumentPromise = (
bucket: GridFSBucket,
docName: string,
trxid: string,
base64data: any,
contentType: any
) => {
constreadable = newReadable();
readable._read = functionnoop() {};
readable.push(base64data);
readable.push(null);
constoptions = {
metadata:
,
contentType,
};
constuploadStream = bucket.openUploadStream(docName, options);
constuploadStreamId = uploadStream.id;
constp = newPromise<string>((resolve, reject) => {
readable
.pipe(uploadStream)
.on("error", function (error: Error)
)
.on("finish", function ()
);
});
returnp;
};