`function.sent` proposal prevents other plugins from transforming subsequent code in the generator function scope
See original GitHub issueSubsequent transforms after using function.sent
in the generator scope are ignored when using shorthand syntax method definition.
When using @babel/babel-plugin-proposal-function-sent together with:
or
The Issue
In a generator function using the shorthand syntax, logical assignments after function.sent
usage are being ignored and not transformed.
let t;
const o = {
*s(){
t ||= 'value'; // former logical assignment - ✔ Transformed
function.sent;
t ||= 'value'; // latter logical assignment - ❌ Not transformed
}
}
Example where function bind isn’t being transformed:
Work around
Use named property instead of shorthand syntax for method definition i.e. the following works:
let t;
const o = {
s: function*(){ // ❗ notice the named property method definition
t ||= 'value'; // former logical assignment - ✔ Transformed
function.sent;
t ||= 'value'; // latter logical assignment - ✔ Transformed
}
}
Version
Babel 7.4.3
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
babel/plugin-proposal-function-sent
Is compiled roughly to let generator = _skipFirstGeneratorNext(function*() { const _functionSent = yield; console.log("Sent", ...
Read more >switch-expression/CHANGELOG.md at master · koblas/switch ...
Babel is a compiler for writing next generation JavaScript. ... #9314 Disallow async functions as loop body. ... babel-plugin-proposal-function-sent ...
Read more >@babel/plugin-transform-block-scoped-functions | Yarn - Package ...
Babel plugin to ensure function declarations at the block level are block scoped. babel-plugin ... The compiler for writing next generation JavaScript.
Read more >function* - JavaScript - MDN Web Docs - Mozilla
When a generator is finished, subsequent next() calls will not execute any of that generator's code, they will just return an object of...
Read more >Top 18 Most Common AngularJS Developer Mistakes - Toptal
function MainController($scope) { $scope.foo = 1; $scope.bar = {innerProperty: 2}; } angular.module('myApp', []) .controller('MainController', ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think that the problem is that the new path isn’t requeued, and thus it isn’t processed by other plugins.
If it has been accidentally fixed we should add a test to prevent future regressions