Recently the conversion of GridFSBucketWriteStream
to type WritableStream
became impossible and leads to a types error.
const wst = svcMng.DBService.projectImageGrid.openUploadStream(image.name);
const uploadPromise = new Promise((resolve, reject) => {
const read = new Readable({
read() {
this.push(image.data);
this.push(null);
}
});
read.on('error', (err) => {
reject(err);
});
read.on('end', () => {
resolve(null);
});
read.pipe(wst);
});
await uploadPromise;
read.pipe(wst)
leads to: Argument of type 'GridFSBucketWriteStream' is not assignable to parameter of type 'WritableStream'.
wst
is a GridFSBucketWriteStream
type and should be convertible to WritableStream
as GridFSBucketWriteStream
class implements NodeJS.WritableStream
.
Of course read.pipe(wst as any)
solve the issue but I would like to avoid it.
read.pipe(wst as NodeJS.WritableStream)
is not working also.
Versions:
- mongoose: 6.1.4
- typescript: 4.1.2
- node v12.16.3
Thank you in advance for the help !