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

TypeError: getBuiltIn(...) is not a constructor #737

Closed
piranna opened this issue Dec 22, 2019 · 3 comments
Closed

TypeError: getBuiltIn(...) is not a constructor #737

piranna opened this issue Dec 22, 2019 · 3 comments

Comments

@piranna
Copy link

piranna commented Dec 22, 2019

--remaining || reject(new (getBuiltIn('AggregateError'))(errors, PROMISE_ANY_ERROR));

I'm using Promise.any(), and when passing my project tests with babel-jest I get the TypeError: getBuiltIn(...) is not a constructor error. Seems like it interpret getBuiltIn function as the constructor, instead of respect the parenthesis and use as constructor the result of the call to getBuiltIn('AggregateError').

.babelrc

{
  "presets": [
    [
      "@babel/preset-env",
      {
        "corejs": {
          "proposals": true,
          "version": 3
        },
        "useBuiltIns": "usage"
      }
    ]
  ]
}

.browserslist

defaults
maintained node versions

package.json

{
  "devDependencies": {
    "@babel/cli": "^7.7.7",
    "@babel/preset-env": "^7.7.7",
    "babel-eslint": "^10.0.3",
    "babel-jest": "^24.9.0",
    "eslint": "^6.8.0",
    "jest-cli": "^24.9.0",
    "prettier": "^1.19.1"
  },
  "dependencies": {
    "core-js": "^3.6.0"
  }
}
@zloirock
Copy link
Owner

The problem in built-ins definitions on the Babel side - on Promise.any should be injected also esnext.agregate-error module. So, please, open this issue in the Babel repo.

@piranna
Copy link
Author

piranna commented Dec 23, 2019

The problem in built-ins definitions on the Babel side - on Promise.any should be injected also esnext.agregate-error module.

You are right, by changing useBuiltIns to entry and adding

require("core-js/modules/esnext.aggregate-error");
require("core-js/modules/esnext.promise.any");

at the top of the file (I know should not use modules directly, it was just a check) it works. Seems like getBuiltIn('AggregateError') is returning undefined, not sure if it should throw an exception with a clear message, or do a check before using the returned value...

So, please, open this issue in the Babel repo.

Done at babel/babel#10910

@piranna
Copy link
Author

piranna commented Dec 27, 2019

This got fixed in babel/babel#10930, thanks for the suggestion of writting them :-)

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