【发布时间】:2018-11-16 02:18:36
【问题描述】:
我想用 Bluebird 来 promiseAll nodejs fs modules 和 Typescript
我的代码
import * as FS from 'fs'
const fs = Bluebird.promisifyAll(FS)
interface fs{
readFileAsync: Function
}
但是当我使用fs.readFileAsync()
tsc 告诉我
[ts] Property 'readFileAsync' does not exist on type 'typeof import("fs")'. Did you mean 'readFileSync'? [2551]
如何告诉 tsc '嗨,fs 对象中还有一个名为 readFileAsync 的函数'?
【问题讨论】:
-
您确定
fs.readFileAsync存在吗?如果您在谈论节点文件系统模块,它不包含readFileAsync函数。 -
顺便提一下,Node v10 及更高版本有
fs.promises,这是一个将每个函数实现为异步的命名空间。
标签: typescript bluebird