-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[babel-jest] Failures on decorators with async methods #5326
Comments
we're seeing this too. i wonder if this has anything to do with |
this seems to go away if we use |
Hah, this is weird. You've found a bug in Babel caused by our use of Using that option produces the following output (reusing your example repo): $ yarn --silent babel --retain-lines index.spec.js
warning package.json: No license field
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {var desc = {};Object['ke' + 'ys'](descriptor).forEach(function (key) {desc[key] = descriptor[key];});desc.enumerable = !!desc.enumerable;desc.configurable = !!desc.configurable;if ('value' in desc || desc.initializer) {desc.writable = true;}desc = decorators.slice().reverse().reduce(function (desc, decorator) {return decorator(target, property, desc) || desc;}, desc);if (context && desc.initializer !== void 0) {desc.value = desc.initializer ? desc.initializer.call(context) : void 0;desc.initializer = undefined;}if (desc.initializer === void 0) {Object['define' + 'Property'](target, property, desc);desc = null;}return desc;}it('supports decorators on async methods', () => {var _class;
const foo = () => {};let
C = (_class = class C {
async
bar() {}}, (_applyDecoratedDescriptor(_class.prototype, "bar", [foo], Object.getOwnPropertyDescriptor(_class.prototype, "bar"), _class.prototype)), _class);
}); async
bar() {} is not valid JS. $ yarn --silent babel --retain-lines index.spec.js | node
warning package.json: No license field
[stdin]:6
bar() {}}, (_applyDecoratedDescriptor(_class.prototype, "bar", [foo], Object.getOwnPropertyDescriptor(_class.prototype, "bar"), _class.prototype)), _class);
^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Object.<anonymous> ([stdin]-wrapper:6:22)
at Module._compile (module.js:643:30)
at evalScript (bootstrap_node.js:462:27)
at Socket.<anonymous> (bootstrap_node.js:233:15)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1055:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11) For comparison, without
@julien-f Can you open up an issue with Babel? This is a bug with either @cpojer thoughts on dropping the @modosc Not related to |
the fix was reverted here and as of |
After merging #5177, we should be OK to remove it again. |
See #5594 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Syntax error when using decorators on async methods:
Repro repo: https://github.com/julien-f/issue-babel-jest-decorators-async-methods
What is the expected behavior?
Should compile and work as if it were previously processed by
@babel/cli
.The text was updated successfully, but these errors were encountered: