-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the generator body to a gen IIFE when compiling its params
- Loading branch information
1 parent
c1d0521
commit b3bcc18
Showing
9 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/babel-plugin-transform-parameters/test/fixtures/parameters/generator/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
function* fn(a, [], b = 2) { | ||
yield a; | ||
yield arguments; | ||
yield this; | ||
return b; | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-transform-parameters/test/fixtures/parameters/generator/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": ["transform-parameters"] | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/babel-plugin-transform-parameters/test/fixtures/parameters/generator/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function fn(a, _ref) { | ||
var _arguments = arguments, | ||
_this = this; | ||
let [] = _ref; | ||
let b = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2; | ||
return function* () { | ||
yield a; | ||
yield _arguments; | ||
yield _this; | ||
return b; | ||
}(); | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/babel-preset-env/test/fixtures/plugins-integration/issue-15012/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function* f([]) {} | ||
|
||
expect(() => f()).toThrow(); | ||
|
||
let called = false; | ||
let run = false; | ||
function* g(x = (called = true)) { | ||
run = true; | ||
} | ||
|
||
g(); | ||
expect(called).toBe(true); | ||
expect(run).toBe(false); |
3 changes: 3 additions & 0 deletions
3
packages/babel-preset-env/test/fixtures/plugins-integration/issue-15012/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function* f([]) {} | ||
|
||
function* g(x = fn()) {} |
3 changes: 3 additions & 0 deletions
3
packages/babel-preset-env/test/fixtures/plugins-integration/issue-15012/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["env"] | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/babel-preset-env/test/fixtures/plugins-integration/issue-15012/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
function f(_ref) { | ||
var _ref2 = babelHelpers.toArray(_ref); | ||
return /*#__PURE__*/babelHelpers.regeneratorRuntime().mark(function _callee() { | ||
return babelHelpers.regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee); | ||
})(); | ||
} | ||
function g() { | ||
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : fn(); | ||
return /*#__PURE__*/babelHelpers.regeneratorRuntime().mark(function _callee2() { | ||
return babelHelpers.regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2); | ||
})(); | ||
} |