Consider the following code:
import redis = require('redis'); //Has ambient declaration from DT import bluebird = require('bluebird'); //Has ambient declaration from DT bluebird.promisifyAll((<any>redis).RedisClient.prototype); bluebird.promisifyAll((<any>redis).Multi.prototype); const client = redis.createClient(); client.getAsync('foo').then(function(res) { console.log(res); });
getAsync will fail because it is created on the fly and is not defined in any .d.ts file. So what is the right way to handle this?
Also, even though I have .d.ts files uploaded for redis, I still need to drop redis to any for promisifyAll . Otherwise, it will throw an error:
Property 'RedisClient' does not exist on type 'typeof "redis"'
Does he any just the easy way?
javascript promise bluebird typescript
Dave
source share