Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

promisfyAll doesn't work with TypeScript 3.9 emitted code #1645

Open
sluukkonen opened this issue May 19, 2020 · 1 comment
Open

promisfyAll doesn't work with TypeScript 3.9 emitted code #1645

sluukkonen opened this issue May 19, 2020 · 1 comment

Comments

@sluukkonen
Copy link

sluukkonen commented May 19, 2020

(This issue tracker is only for bug reports or feature requests, if this is neither, please choose appropriate channel from http://bluebirdjs.com/docs/support.html)

Please answer the questions the best you can:

  1. What version of bluebird is the issue happening on? 3.7.2

  2. What platform and version? (For example Node.js 0.12 or Google Chrome 32) Node.js 12

  3. Did this issue happen with earlier version of bluebird?

TypeScript 3.9 emits the following kind of code with "esModuleInterop": true for importing modules, due to this change

Source code:

// @ts-nocheck
import * as Bluebird from 'bluebird'
import * as fs from 'fs'

const promisified = Bluebird.promisifyAll(fs)

console.log(promisified.readFileAsync) // undefined

Compiled code:

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
exports.__esModule = true;
// @ts-nocheck
var Bluebird = __importStar(require("bluebird"));
var fs = __importStar(require("fs"));
var promisified = Bluebird.promisifyAll(fs);
console.log(promisified.readFileAsync); // undefined

This change causes Bluebird.promisifyAll to fail to add any promisified methods, since util.inheritedDataKeys ignores getters if in ES5 mode.

I'm not sure who is to blame here (so to speak), but opening this issue in any case.

@benjamingr
Copy link
Collaborator

So the bug is specifically for es modules being promsified?

I'm fine with adding a check for the specific case there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants