[ad_1]
I'm trying to use util.promisify with Typescript and "strict": true in compiler options.
Using node 9.7.1
Typescript 2.7.2
if I try to use util.promisify
const p = util.promisify(libfirebird.attach);
this.dbHandle = await p(connectionParams);
I get error "Expected 2 arguments, but got 1." in "p(connectionParams)"
I try to use this way
this.dbHandle = await util.promisify(libfirebird.attach)(connectionParams);
but same problem.
The solution that I found is to manually construct the promise:
this.dbHandle = await new Promise<libfirebird.Database>((resolve, reject) =>
libfirebird.attach(connectionParams, function(err, db)
if (err) return reject(err);
resolve(db);
);
);
Is there any know bug with util.promisify in typescript or I missing something?
[ad_2]
لینک منبع