繁体   English   中英

Typescript nodejs Stream on event:“void”类型的参数不可分配给“(...args:any [])=> void”类型的参数

Typescript nodejs Stream on event: Argument of type 'void' is not assignable to parameter of type '(...args: any[]) => void'

提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供   中文繁体   英文版本   中英对照 版本,有任何建议请联系yoyou2525@163.com。

这要了我的命:


  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.

 
粤ICP备18138465号  © 2020-2022 STACKOOM.COM