I'm just learning typescript. In javascript, I use bluebird to promisifyAll
fs, using a version of fs.existsAsync from https://github.com/petkaantonov/bluebird/issues/418:
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)
})
})
However, typescript complains:
error TS2339: Property 'existsAsync' does not exist on type 'typeof "fs"'.
Is there a best practice to get around this?