
[英]Argument of type '(event: string) => void' is not assignable to parameter of type 'EventListenerOrEventListenerObject
[英]Typescript nodejs Stream on event: Argument of type 'void' is not assignable to parameter of type '(...args: any[]) => void'
这要了我的命:
const streamPassThrough = new Stream.PassThrough();
// 4. define the s3 Upload stream; and connect streamPassThrough to it;
const s3Upload = new Upload({
client: s3Client,
params: {Bucket: bucketName, Key: zippedFileKey, Body: streamPassThrough},
partSize: 10 * 1024 * 1024,
queueSize: 1,
});
s3Upload.on("httpUploadProgress", (progress) => {
logger.info(`S3StreamZip / s3Upload on httpUploadProgress : ${progress}`);
});
await new Promise<void>((resolve, reject) => {
logger.info("Starting upload of the output Files Zip Archive");
streamPassThrough.on('close', resolve());
streamPassThrough.on('end', resolve());
streamPassThrough.on('error', reject());
archive.pipe(streamPassThrough);
s3FilesDownloadSteams.forEach((item) => {
archive.append(item.stream, { name: item.fileName })
});
archive.finalize();
return 'stream flow done'
}).catch((error) => {
logger.error(`Stream flow error: ${error.name} ${error.code} ${error.message} ${error.path} ${error.stack}`);
throw new Error(`${error.code} ${error.message} ${error.data}`);
});
当我尝试yarn start
,出现以下编译错误:
src/services/attachment.ts:304:35 - error TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type 'void' is not assignable to parameter of type '(...args: any[]) => void'.
304 streamPassThrough.on('close', resolve());
~~~~~~~~~
node_modules/@types/node/stream.d.ts:73:13
73 on(event: string | symbol, listener: (...args: any[]) => void): this;
~~
The last overload is declared here.
src/services/attachment.ts:305:33 - error TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type 'void' is not assignable to parameter of type '(...args: any[]) => void'.
305 streamPassThrough.on('end', resolve());
~~~~~~~~~
node_modules/@types/node/stream.d.ts:73:13
73 on(event: string | symbol, listener: (...args: any[]) => void): this;
~~
The last overload is declared here.
src/services/attachment.ts:306:35 - error TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type 'void' is not assignable to parameter of type '(...args: any[]) => void'.
306 streamPassThrough.on('error', reject());
~~~~~~~~
这是什么意思??? 代码在 nodejs 中,但在 typescript 中它抛出了这些错误。 我该如何解决?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.