如何在打字稿

时间:2017-06-27 06:56:43

标签: javascript typescript promise

我只是在学习打字稿。在javascript中,我使用bluebird到promisifyAll fs,使用来自https://github.com/petkaantonov/bluebird/issues/418的fs.existsAsync版本:

import * as Promise from 'bluebird'
import * as fs from 'fs'

Promise.promisifyAll(fs)

fs.existsAsync = Promise.promisify(
  // istanbul ignore next
  function exists2 (
      path : string,
      exists2callback : (err:null, exists: boolean) => void) {
    fs.exists(path, function callbackWrapper (exists) {
      exists2callback(null, exists)
    })
  })

然而,打字稿抱怨:

error TS2339: Property 'existsAsync' does not exist on type 'typeof "fs"'.

有最好的做法可以解决这个问题吗?

0 个答案:

没有答案
相关问题