File tree Expand file tree Collapse file tree
babel-plugin-transform-async-to-generator/test/fixtures/regression/4943
babel-plugin-transform-parameters
test/fixtures/parameters/generator
babel-preset-env/test/fixtures/plugins-integration/issue-15012 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,11 +7,13 @@ function foo(_x) {
77 return _foo . apply ( this , arguments ) ;
88}
99function _foo ( ) {
10- _foo = babelHelpers . asyncToGenerator ( function * ( _ref ) {
10+ _foo = babelHelpers . asyncToGenerator ( function ( _ref ) {
1111 let a = _ref . a ,
1212 _ref$b = _ref . b ,
1313 b = _ref$b === void 0 ? mandatory ( "b" ) : _ref$b ;
14- return Promise . resolve ( b ) ;
14+ return function * ( ) {
15+ return Promise . resolve ( b ) ;
16+ } ( ) ;
1517 } ) ;
1618 return _foo . apply ( this , arguments ) ;
1719}
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ export default function convertFunctionParams(
154154 // ensure it's a block, useful for arrow functions
155155 path . ensureBlock ( ) ;
156156
157- if ( state . needsOuterBinding || shadowedParams . size > 0 ) {
157+ if ( state . needsOuterBinding || shadowedParams . size > 0 || node . generator ) {
158158 body . push ( buildScopeIIFE ( shadowedParams , path . node . body ) ) ;
159159
160160 path . set ( "body" , t . blockStatement ( body as t . Statement [ ] ) ) ;
Original file line number Diff line number Diff line change 1+ function * fn ( a , [ ] , b = 2 ) {
2+ yield a ;
3+ yield arguments ;
4+ yield this ;
5+ return b ;
6+ }
Original file line number Diff line number Diff line change 1+ {
2+ "plugins" : [" transform-parameters" ]
3+ }
Original file line number Diff line number Diff line change 1+ function fn ( a , _ref ) {
2+ var _arguments = arguments ,
3+ _this = this ;
4+ let [ ] = _ref ;
5+ let b = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : 2 ;
6+ return function * ( ) {
7+ yield a ;
8+ yield _arguments ;
9+ yield _this ;
10+ return b ;
11+ } ( ) ;
12+ }
Original file line number Diff line number Diff line change 1+ function * f ( [ ] ) { }
2+
3+ expect ( ( ) => f ( ) ) . toThrow ( ) ;
4+
5+ let called = false ;
6+ let run = false ;
7+ function * g ( x = ( called = true ) ) {
8+ run = true ;
9+ }
10+
11+ g ( ) ;
12+ expect ( called ) . toBe ( true ) ;
13+ expect ( run ) . toBe ( false ) ;
Original file line number Diff line number Diff line change 1+ function * f ( [ ] ) { }
2+
3+ function * g ( x = fn ( ) ) { }
Original file line number Diff line number Diff line change 1+ {
2+ "presets" : [" env" ]
3+ }
Original file line number Diff line number Diff line change 1+ function f ( _ref ) {
2+ var _ref2 = babelHelpers . toArray ( _ref ) ;
3+ return /*#__PURE__*/ babelHelpers . regeneratorRuntime ( ) . mark ( function _callee ( ) {
4+ return babelHelpers . regeneratorRuntime ( ) . wrap ( function _callee$ ( _context ) {
5+ while ( 1 ) {
6+ switch ( _context . prev = _context . next ) {
7+ case 0 :
8+ case "end" :
9+ return _context . stop ( ) ;
10+ }
11+ }
12+ } , _callee ) ;
13+ } ) ( ) ;
14+ }
15+ function g ( ) {
16+ var x = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : fn ( ) ;
17+ return /*#__PURE__*/ babelHelpers . regeneratorRuntime ( ) . mark ( function _callee2 ( ) {
18+ return babelHelpers . regeneratorRuntime ( ) . wrap ( function _callee2$ ( _context2 ) {
19+ while ( 1 ) {
20+ switch ( _context2 . prev = _context2 . next ) {
21+ case 0 :
22+ case "end" :
23+ return _context2 . stop ( ) ;
24+ }
25+ }
26+ } , _callee2 ) ;
27+ } ) ( ) ;
28+ }
You can’t perform that action at this time.
0 commit comments