javascript - TypeScript:如何在 basic-ftp NodeJS 模块中引用 internal.Writable?
问题描述
在basic-ftp 模块 API 文档中,我读到:
downloadTo(writableStream | localPath, remotePath, startAt = 0): Promise<FTPResponse>
但是当我将模块链接到 TypeScript 项目时,我读到:
(method) Client.downloadTo(destination: string | internal.Writable, fromRemotePath: string, startAt?: number | undefined): Promise<bf.FTPResponse>
因此,虽然我WritableStream
在 TypeScript 中有输入(@types/node
至少有),但我没有(出于明显的原因)该internal.Writable
类型。
我试图将其包装在“帮助器”方法中(只是为了简化我的特定应用程序中的任务),如下所示:
function get(file: string, contents : WritableStream) : boolean {
if (!connected()) {
log_err("Attempt to get() without an active FTP connection.");
}
ftp_client.downloadTo(contents, file);
}
然后打电话给downloadTo()
我从 IntelliSense 收到消息:
Argument of type 'WritableStream<any>' is not assignable to parameter of type 'string | Writable'.
我在这里想念什么?虽然我希望不能仅仅从WritableStream
to中“隐式转换” internal.Writable
,但我不确定该指向哪里。
我正在使用的一些版本:
╔═════════════╦═════════╗
║ Software ║ Version ║
╠═════════════╬═════════╣
║ TSC ║ 3.8.3 ║
║ NodeJS ║ 12.16.2 ║
║ NPM ║ 6.14.4 ║
║ @types/node ║ 13.11.1 ║
║ basic-ftp ║ 4.5.4 ║
║ Windows 10 ║ 1903 ║
║ VSCode ║ 1.44.2 ║
╚═════════════╩═════════╝
解决方案
好的,我错过了:
import { Writable } from "stream";
通过检查 basic-ftp 的src/Client.ts 文件(或只是本地文件Client.d.ts
)发现了这一点。
推荐阅读
- javascript - 为什么 e.status 在 ajax 请求的成功函数中变得未定义?
- python - 熊猫数据帧交错重新排序
- c# - 将配置文件数据添加到 ASP.NetCore Identity 时出现迁移错误
- list - Pandas 基于相互依赖的滞后值计算列
- python - Pandas:遍历列并从一列开始
- angular - 用于 Angular 应用程序的动态基本 URL 的 Okta 隐式回调问题
- java - Spring boot 不提供 src/main/resources/public 目录中的某些图像
- google-maps - 有没有办法根据时间使用纬度和经度来获取图像?
- java - 即使应用程序在一天内关闭,如何生成唯一随机数
- pygame - 如何让我的子弹在pygame中移动