diff --git a/ecmascript/transforms/compat/src/es2015/mod.rs b/ecmascript/transforms/compat/src/es2015/mod.rs index 341eeb27edb..d1fc3f3b43f 100644 --- a/ecmascript/transforms/compat/src/es2015/mod.rs +++ b/ecmascript/transforms/compat/src/es2015/mod.rs @@ -56,10 +56,10 @@ where for_of(c.for_of), // Should come before parameters // See: https://github.com/swc-project/swc/issues/1036 - regenerator(c.regenerator, global_mark), parameters(), computed_properties(), destructuring(c.destructuring), + regenerator(c.regenerator, global_mark), block_scoping(), ) } diff --git a/ecmascript/transforms/compat/tests/es2015_block_scoping.rs b/ecmascript/transforms/compat/tests/es2015_block_scoping.rs index 13e7d5c35f7..e020d4d23a2 100644 --- a/ecmascript/transforms/compat/tests/es2015_block_scoping.rs +++ b/ecmascript/transforms/compat/tests/es2015_block_scoping.rs @@ -529,14 +529,15 @@ test!( 3 ] ].map(_asyncToGenerator(regeneratorRuntime.mark(function _callee(param) { - var _param = _slicedToArray(param, 1), a = _param[0]; + var _param, a; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: + _param = _slicedToArray(param, 1), a = _param[0]; return _ctx.abrupt("return", Promise.resolve().then(function() { return a * 2; })); - case 1: + case 2: case "end": return _ctx.stop(); } diff --git a/tests/fixture/issue-1449/case1/output/index.js b/tests/fixture/issue-1449/case1/output/index.js index 96903190407..c975b8f01c7 100644 --- a/tests/fixture/issue-1449/case1/output/index.js +++ b/tests/fixture/issue-1449/case1/output/index.js @@ -28,16 +28,17 @@ function _asyncToGenerator(fn) { }); }; } +function _throw(e) { + throw e; +} function _foo() { _foo = _asyncToGenerator(regeneratorRuntime.mark(function _callee() { + var tmp, ref, ref; return regeneratorRuntime.wrap(function _callee$(_ctx) { - var ref; while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref1; - var ref2; - ref1 = baz, ref = { - }, ref2 = ref, ref2, ref1; + tmp = baz.bar, ref = tmp === void 0 ? { + } : tmp, ref = ref !== null ? ref : _throw(new TypeError("Cannot destructure undefined")); case 1: case "end": return _ctx.stop(); diff --git a/tests/fixture/issue-1477/case1/output/index.js b/tests/fixture/issue-1477/case1/output/index.js index 4435d4cc4b0..fafa2b44433 100644 --- a/tests/fixture/issue-1477/case1/output/index.js +++ b/tests/fixture/issue-1477/case1/output/index.js @@ -1,4 +1,7 @@ import regeneratorRuntime from "regenerator-runtime"; +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); @@ -28,15 +31,41 @@ function _asyncToGenerator(fn) { }); }; } +function _iterableToArrayLimit(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + try { + for(var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true){ + _arr.push(_s.value); + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally{ + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally{ + if (_d) throw _e; + } + } + return _arr; +} +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); +} +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); +} function _f() { _f = _asyncToGenerator(regeneratorRuntime.mark(function _callee(a, b) { - var a_; + var ref, ref1, tmp, a_; return regeneratorRuntime.wrap(function _callee$(_ctx) { - var ref; while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref1, ref2; - ref1 = JSON.parse(b), ref2 = ref1[0], ref = 1, a_ = ref, ref2, ref1; + ref = _slicedToArray(JSON.parse(b), 1), ref1 = ref[0], tmp = ref1.a, a_ = tmp === void 0 ? 1 : tmp; case 1: case "end": return _ctx.stop(); diff --git a/tests/fixture/issue-1718/case1/output/index.ts b/tests/fixture/issue-1718/case1/output/index.ts index 4801ea4ad4b..35a00ce9c2f 100644 --- a/tests/fixture/issue-1718/case1/output/index.ts +++ b/tests/fixture/issue-1718/case1/output/index.ts @@ -35,70 +35,70 @@ function _scanUser() { case 0: _ctx1.next = 2; return Promise.all(groups.map(_asyncToGenerator(regeneratorRuntime.mark(function _callee(param) { - var users = param.users; - var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, user; + var users, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, user; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: + users = param.users; _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; - _ctx.prev = 1; + _ctx.prev = 2; _iterator = users[Symbol.iterator](); - case 3: + case 4: if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { - _ctx.next = 11; + _ctx.next = 12; break; } user = _step.value; console.log('user', user); - _ctx.next = 8; + _ctx.next = 9; return new Promise(function(resolve) { return setTimeout(resolve, 30); }); - case 8: + case 9: _iteratorNormalCompletion = true; - _ctx.next = 3; + _ctx.next = 4; break; - case 11: - _ctx.next = 17; + case 12: + _ctx.next = 18; break; - case 13: - _ctx.prev = 13; - _ctx.t0 = _ctx["catch"](1); + case 14: + _ctx.prev = 14; + _ctx.t0 = _ctx["catch"](2); _didIteratorError = true; _iteratorError = _ctx.t0; - case 17: - _ctx.prev = 17; + case 18: _ctx.prev = 18; + _ctx.prev = 19; if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } - case 20: - _ctx.prev = 20; + case 21: + _ctx.prev = 21; if (!_didIteratorError) { - _ctx.next = 23; + _ctx.next = 24; break; } throw _iteratorError; - case 23: - return _ctx.finish(20); case 24: - return _ctx.finish(17); + return _ctx.finish(21); case 25: + return _ctx.finish(18); + case 26: case "end": return _ctx.stop(); } }, _callee, null, [ [ - 1, - 13, - 17, - 25 + 2, + 14, + 18, + 26 ], [ - 18, + 19, , - 20, - 24 + 21, + 25 ] ]); })))); diff --git a/tests/fixture/issue-2232/case1/output/index.js b/tests/fixture/issue-2232/case1/output/index.js index ec34851de74..805ee54a120 100644 --- a/tests/fixture/issue-2232/case1/output/index.js +++ b/tests/fixture/issue-2232/case1/output/index.js @@ -87,13 +87,11 @@ var Foo = /*#__PURE__*/ function() { key: "sendSomeMessage", value: function sendSomeMessage(_parent, _param, _param1) { return _asyncToGenerator(regeneratorRuntime.mark(function _callee() { - var toNumber, messageBody, all, dataSources; + var _input, toNumber, messageBody, all, dataSources; return regeneratorRuntime.wrap(function _callee$(_ctx) { - var ref; while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref1; - ref1 = _param, ref = ref1.input, toNumber = ref.toNumber, messageBody = ref.messageBody, ref, ref1, all = _objectWithoutProperties(_param.input, [ + _input = _param.input, toNumber = _input.toNumber, messageBody = _input.messageBody, all = _objectWithoutProperties(_param.input, [ "toNumber", "messageBody" ]), dataSources = _param1.dataSources; diff --git a/tests/fixture/issue-2232/case2/output/index.ts b/tests/fixture/issue-2232/case2/output/index.ts index 81d143a2d24..281b97ff100 100644 --- a/tests/fixture/issue-2232/case2/output/index.ts +++ b/tests/fixture/issue-2232/case2/output/index.ts @@ -61,13 +61,11 @@ function _objectWithoutPropertiesLoose(source, excluded) { var resolver = { sendSomeMessage: function(_parent, _param, _param1) { return _asyncToGenerator(regeneratorRuntime.mark(function _callee() { - var toNumber, messageBody, all, dataSources; + var _input, toNumber, messageBody, all, dataSources; return regeneratorRuntime.wrap(function _callee$(_ctx) { - var ref; while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref1; - ref1 = _param, ref = ref1.input, toNumber = ref.toNumber, messageBody = ref.messageBody, ref, ref1, all = _objectWithoutProperties(_param.input, [ + _input = _param.input, toNumber = _input.toNumber, messageBody = _input.messageBody, all = _objectWithoutProperties(_param.input, [ "toNumber", "messageBody" ]), dataSources = _param1.dataSources; diff --git a/tests/fixture/issue-2413/1/input/index.js b/tests/fixture/issue-2413/1/input/index.js new file mode 100644 index 00000000000..3f228dd5b82 --- /dev/null +++ b/tests/fixture/issue-2413/1/input/index.js @@ -0,0 +1,9 @@ +const handleSubmit = useMutation(async () => { + try { + const res = await gate.register({ username: phoneNumber }); + setstep((prev) => prev + 1); + toast.success(res.message); + } catch ({ data: { errors } }) { + showErrorMessage(errors); + } +}); \ No newline at end of file diff --git a/tests/fixture/issue-2413/1/output/index.js b/tests/fixture/issue-2413/1/output/index.js new file mode 100644 index 00000000000..6e3cd014697 --- /dev/null +++ b/tests/fixture/issue-2413/1/output/index.js @@ -0,0 +1,64 @@ +import regeneratorRuntime from "regenerator-runtime"; +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } +} +function _asyncToGenerator(fn) { + return function() { + var self = this, args = arguments; + return new Promise(function(resolve, reject) { + var gen = fn.apply(self, args); + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + _next(undefined); + }); + }; +} +var handleSubmit = useMutation(_asyncToGenerator(regeneratorRuntime.mark(function _callee() { + var res, errors; + return regeneratorRuntime.wrap(function _callee$(_ctx) { + while(1)switch(_ctx.prev = _ctx.next){ + case 0: + _ctx.prev = 0; + _ctx.next = 3; + return gate.register({ + username: phoneNumber + }); + case 3: + res = _ctx.sent; + setstep(function(prev) { + return prev + 1; + }); + toast.success(res.message); + _ctx.next = 12; + break; + case 8: + _ctx.prev = 8; + _ctx.t0 = _ctx["catch"](0); + errors = _ctx.t0.data.errors; + showErrorMessage(errors); + case 12: + case "end": + return _ctx.stop(); + } + }, _callee, null, [ + [ + 0, + 8 + ] + ]); +}))); diff --git a/tests/fixture/next.js/shared/lib/router/1/output/index.ts b/tests/fixture/next.js/shared/lib/router/1/output/index.ts index 41e36cf81d3..c936a165e16 100644 --- a/tests/fixture/next.js/shared/lib/router/1/output/index.ts +++ b/tests/fixture/next.js/shared/lib/router/1/output/index.ts @@ -57,7 +57,7 @@ var Router = /*#__PURE__*/ function() { key: "change", value: function change(method, url, as, options, forcedScroll) { return _asyncToGenerator(regeneratorRuntime.mark(function _callee() { - var shouldResolveHref, prevLocale, parsedAs, localePathResult, didNavigate, ref, detectedDomain, asNoBasePath, shallow, routeProps, cleanedAs, localeChange, parsed, pathname, query, pages, rewrites, resolvedAs, rewritesResult, route, parsedAs1, asPathname, routeRegex, routeMatch, shouldInterpolate, interpolatedAs, missingParams, ref1, ref2, routeInfo, error, props, __N_SSG, __N_SSP, destination, parsedHref, newUrl, newAs, notFoundRoute, isValidShallowRoute, _scroll, shouldScroll, resetScroll; + var shouldResolveHref, prevLocale, parsedAs, localePathResult, didNavigate, ref, detectedDomain, asNoBasePath, _shallow, shallow, routeProps, cleanedAs, localeChange, parsed, pathname, query, pages, rewrites, ref1, resolvedAs, rewritesResult, route, parsedAs1, asPathname, routeRegex, routeMatch, shouldInterpolate, interpolatedAs, missingParams, ref2, ref3, routeInfo, error, props, __N_SSG, __N_SSP, destination, parsedHref, ref4, newUrl, newAs, notFoundRoute, isValidShallowRoute, _scroll, shouldScroll, resetScroll; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: @@ -133,8 +133,7 @@ var Router = /*#__PURE__*/ function() { if (ST) { performance.mark('routeChange'); } - var ref8, ref3; - ref8 = options, ref3 = ref8.shallow, shallow = ref3 === void 0 ? false : ref3, ref8; + _shallow = options.shallow, shallow = _shallow === void 0 ? false : _shallow; routeProps = { shallow: shallow }; @@ -159,29 +158,30 @@ var Router = /*#__PURE__*/ function() { return _ctx.abrupt("return", true); case 35: parsed = parseRelativeUrl(url); - var ref4; - ref4 = parsed, pathname = ref4.pathname, query = ref4.query, ref4; + pathname = parsed.pathname, query = parsed.query; ; _ctx.prev = 38; _ctx.next = 41; return this.pageLoader.getPageList(); case 41: pages = _ctx.sent; - _ctx.next = 44; + ; + _ctx.next = 45; return getClientBuildManifest(); - case 44: - var ref5; - ref5 = _ctx.sent, rewrites = ref5.__rewrites, ref5; - _ctx.next = 51; + case 45: + ref1 = _ctx.sent; + rewrites = ref1.__rewrites; + ref1; + _ctx.next = 54; break; - case 47: - _ctx.prev = 47; + case 50: + _ctx.prev = 50; _ctx.t0 = _ctx["catch"](38); // If we fail to resolve the page list or client-build manifest, we must // do a server-side transition: window.location.href = as; return _ctx.abrupt("return", false); - case 51: + case 54: // If asked to change the current URL we should reload the current page // (not location.reload() but reload getInitialProps and other Next.js stuffs) // We also need to set the method = replaceState always @@ -220,21 +220,21 @@ var Router = /*#__PURE__*/ function() { } route = removePathTrailingSlash(pathname); if (isLocalURL(as)) { - _ctx.next = 61; + _ctx.next = 64; break; } if (!(process.env.NODE_ENV !== 'production')) { - _ctx.next = 59; + _ctx.next = 62; break; } throw new Error("Invalid href: \"".concat(url, "\" and as: \"").concat(as, "\", received relative href and external as") + "\nSee more info: https://nextjs.org/docs/messages/invalid-relative-url-external-as"); - case 59: + case 62: window.location.href = as; return _ctx.abrupt("return", false); - case 61: + case 64: resolvedAs = delLocale(delBasePath(resolvedAs), this.locale); if (!isDynamicRoute(route)) { - _ctx.next = 77; + _ctx.next = 80; break; } parsedAs1 = parseRelativeUrl(resolvedAs); @@ -245,24 +245,24 @@ var Router = /*#__PURE__*/ function() { interpolatedAs = shouldInterpolate ? interpolateAs(route, asPathname, query) : { }; if (!(!routeMatch || shouldInterpolate && !interpolatedAs.result)) { - _ctx.next = 76; + _ctx.next = 79; break; } missingParams = Object.keys(routeRegex.groups).filter(function(param) { return !query[param]; }); if (!(missingParams.length > 0)) { - _ctx.next = 74; + _ctx.next = 77; break; } if (process.env.NODE_ENV !== 'production') { console.warn("".concat(shouldInterpolate ? "Interpolating href" : "Mismatching `as` and `href`", " failed to manually provide ") + "the params: ".concat(missingParams.join(', '), " in the `href`'s `query`")); } throw new Error((shouldInterpolate ? "The provided `href` (".concat(url, ") value is missing query values (").concat(missingParams.join(', '), ") to be interpolated properly. ") : "The provided `as` value (".concat(asPathname, ") is incompatible with the `href` value (").concat(route, "). ")) + "Read more: https://nextjs.org/docs/messages/".concat(shouldInterpolate ? 'href-interpolation-failed' : 'incompatible-href-as')); - case 74: - _ctx.next = 77; + case 77: + _ctx.next = 80; break; - case 76: + case 79: if (shouldInterpolate) { as = formatWithValidation(Object.assign({ }, parsedAs1, { @@ -273,67 +273,65 @@ var Router = /*#__PURE__*/ function() { // Merge params into `query`, overwriting any specified in search Object.assign(query, routeMatch); } - case 77: + case 80: Router.events.emit('routeChangeStart', as, routeProps); - _ctx.prev = 78; + _ctx.prev = 81; ; - _ctx.next = 82; + _ctx.next = 85; return this.getRouteInfo(route, pathname, query, as, resolvedAs, routeProps); - case 82: + case 85: routeInfo = _ctx.sent; - var ref6; - ref6 = routeInfo, error = ref6.error, props = ref6.props, __N_SSG = ref6.__N_SSG, __N_SSP = ref6.__N_SSP, ref6; + error = routeInfo.error, props = routeInfo.props, __N_SSG = routeInfo.__N_SSG, __N_SSP = routeInfo.__N_SSP; if (!((__N_SSG || __N_SSP) && props)) { - _ctx.next = 109; + _ctx.next = 112; break; } if (!(props.pageProps && props.pageProps.__N_REDIRECT)) { - _ctx.next = 94; + _ctx.next = 97; break; } destination = props.pageProps.__N_REDIRECT; if (!(destination.startsWith('/') && props.pageProps.__N_REDIRECT_BASE_PATH !== false)) { - _ctx.next = 92; + _ctx.next = 95; break; } parsedHref = parseRelativeUrl(destination); parsedHref.pathname = resolveDynamicRoute(parsedHref.pathname, pages); - var ref7; - ref7 = prepareUrlAs(this, destination, destination), newUrl = ref7.url, newAs = ref7.as, ref7; + ref4 = prepareUrlAs(this, destination, destination), newUrl = ref4.url, newAs = ref4.as; return _ctx.abrupt("return", this.change(method, newUrl, newAs, options)); - case 92: + case 95: window.location.href = destination; return _ctx.abrupt("return", new Promise(function() { })); - case 94: + case 97: this.isPreview = !!props.__N_PREVIEW; if (!(props.notFound === SSG_DATA_NOT_FOUND)) { - _ctx.next = 109; + _ctx.next = 112; break; } ; - _ctx.prev = 97; - _ctx.next = 100; + _ctx.prev = 100; + _ctx.next = 103; return this.fetchComponent('/404'); - case 100: - notFoundRoute = '/404'; - _ctx.next = 106; - break; case 103: - _ctx.prev = 103; - _ctx.t1 = _ctx["catch"](97); - notFoundRoute = '/_error'; + notFoundRoute = '/404'; + _ctx.next = 109; + break; case 106: - _ctx.next = 108; + _ctx.prev = 106; + _ctx.t1 = _ctx["catch"](100); + notFoundRoute = '/_error'; + case 109: + _ctx.next = 111; return this.getRouteInfo(notFoundRoute, notFoundRoute, query, as, resolvedAs, { shallow: false }); - case 108: + case 111: routeInfo = _ctx.sent; - case 109: + case 112: Router.events.emit('beforeHistoryChange', as, routeProps); this.changeState(method, url, as, options); - if (options._h && pathname === '/_error' && ((ref1 = self.__NEXT_DATA__.props) === null || ref1 === void 0 ? void 0 : (ref2 = ref1.pageProps) === null || ref2 === void 0 ? void 0 : ref2.statusCode) === 500 && (props === null || props === void 0 ? void 0 : props.pageProps)) { + if (options._h && pathname === '/_error' && ((ref2 = self.__NEXT_DATA__.props) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.pageProps) === null || ref3 === void 0 ? void 0 : ref3.statusCode) === 500 && (props === null || props === void 0 ? void 0 : props.pageProps)) { // ensure statusCode is still correct for static 500 page // when updating query information props.pageProps.statusCode = 500; @@ -345,19 +343,19 @@ var Router = /*#__PURE__*/ function() { x: 0, y: 0 } : null; - _ctx.next = 118; + _ctx.next = 121; return this.set(route, pathname, query, cleanedAs, routeInfo, forcedScroll !== null && forcedScroll !== void 0 ? forcedScroll : resetScroll).catch(function(e) { if (e.cancelled) error = error || e; else throw e; }); - case 118: + case 121: if (!error) { - _ctx.next = 121; + _ctx.next = 124; break; } Router.events.emit('routeChangeError', error, cleanedAs, routeProps); throw error; - case 121: + case 124: if (process.env.__NEXT_I18N_SUPPORT) { if (this.locale) { document.documentElement.lang = this.locale; @@ -365,32 +363,32 @@ var Router = /*#__PURE__*/ function() { } Router.events.emit('routeChangeComplete', as, routeProps); return _ctx.abrupt("return", true); - case 126: - _ctx.prev = 126; - _ctx.t2 = _ctx["catch"](78); + case 129: + _ctx.prev = 129; + _ctx.t2 = _ctx["catch"](81); if (!(isError(_ctx.t2) && _ctx.t2.cancelled)) { - _ctx.next = 130; + _ctx.next = 133; break; } return _ctx.abrupt("return", false); - case 130: + case 133: throw _ctx.t2; - case 131: + case 134: case "end": return _ctx.stop(); } }, _callee, this, [ [ 38, - 47 + 50 ], [ - 78, - 126 + 81, + 129 ], [ - 97, - 103 + 100, + 106 ] ]); }).bind(this))(); diff --git a/tests/tsc-references/async/es2017/asyncMethodWithSuperConflict_es6/input.ts/es5.1.normal/output.js b/tests/tsc-references/async/es2017/asyncMethodWithSuperConflict_es6/input.ts/es5.1.normal/output.js index b04d6785c0b..8084bbf35f2 100644 --- a/tests/tsc-references/async/es2017/asyncMethodWithSuperConflict_es6/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/async/es2017/asyncMethodWithSuperConflict_es6/input.ts/es5.1.normal/output.js @@ -300,7 +300,7 @@ var B = /*#__PURE__*/ function(A) { return _get(_getPrototypeOf(B.prototype), "x", _this11); }; return _asyncToGenerator(regeneratorRuntime.mark(function _callee() { - var _super, _superIndex, f, a, b; + var _super, _superIndex, f, a, b, ref, ref1; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: @@ -314,17 +314,17 @@ var B = /*#__PURE__*/ function(A) { b = _super_method2(); _super_x3(f); _super_method3(f); - var ref; + ; // destructuring assign with property access (ref = { f: f }, _super_x4() = ref.f, ref); - var ref1; + ; // destructuring assign with element access (ref1 = { f: f }, _super_method4() = ref1.f, ref1); - case 11: + case 13: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/async/es2017/asyncMethodWithSuperConflict_es6/input.ts/es5.2.minified/output.js b/tests/tsc-references/async/es2017/asyncMethodWithSuperConflict_es6/input.ts/es5.2.minified/output.js index e3b5581b272..de0fe3e6312 100644 --- a/tests/tsc-references/async/es2017/asyncMethodWithSuperConflict_es6/input.ts/es5.2.minified/output.js +++ b/tests/tsc-references/async/es2017/asyncMethodWithSuperConflict_es6/input.ts/es5.2.minified/output.js @@ -181,18 +181,18 @@ var A = function() { return _get(_getPrototypeOf(B.prototype), "x", _this11); }; return _asyncToGenerator(regeneratorRuntime.mark(function _callee() { - var _super, _superIndex, f, a, b; + var _super, _superIndex, f, a, b, ref, ref1; return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - var ref, ref1, _args, _args1; + var _args, _args1; _super = null, _superIndex = null, f = function() { }, _super_x(), _super_method(), a = _get(_getPrototypeOf(B.prototype), "x", _this6), b = _get(_getPrototypeOf(B.prototype), "x", _this7), _args = f, _set(_getPrototypeOf(B.prototype), "x", _args, _this8, !0), _args1 = f, _set(_getPrototypeOf(B.prototype), "x", _args1, _this9, !0), ref = { f: f }, _super_x1() = ref.f, ref1 = { f: f }, _super_method1() = ref1.f; - case 11: + case 13: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/async/es2017/asyncMethodWithSuper_es2017/input.ts/es5.1.normal/output.js b/tests/tsc-references/async/es2017/asyncMethodWithSuper_es2017/input.ts/es5.1.normal/output.js index c924b4a18b6..78c02831a8b 100644 --- a/tests/tsc-references/async/es2017/asyncMethodWithSuper_es2017/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/async/es2017/asyncMethodWithSuper_es2017/input.ts/es5.1.normal/output.js @@ -299,7 +299,7 @@ var B = /*#__PURE__*/ function(A) { return _get(_getPrototypeOf(B.prototype), "x", _this11); }; return _asyncToGenerator(regeneratorRuntime.mark(function _callee() { - var f, a, b; + var f, a, b, ref, ref1; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: @@ -311,17 +311,17 @@ var B = /*#__PURE__*/ function(A) { b = _super_method2(); _super_x3(f); _super_method3(f); - var ref; + ; // destructuring assign with property access (ref = { f: f }, _super_x4() = ref.f, ref); - var ref1; + ; // destructuring assign with element access (ref1 = { f: f }, _super_method4() = ref1.f, ref1); - case 9: + case 11: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/async/es2017/asyncMethodWithSuper_es2017/input.ts/es5.2.minified/output.js b/tests/tsc-references/async/es2017/asyncMethodWithSuper_es2017/input.ts/es5.2.minified/output.js index 0199979d65b..d10648f12c4 100644 --- a/tests/tsc-references/async/es2017/asyncMethodWithSuper_es2017/input.ts/es5.2.minified/output.js +++ b/tests/tsc-references/async/es2017/asyncMethodWithSuper_es2017/input.ts/es5.2.minified/output.js @@ -181,18 +181,18 @@ var A = function() { return _get(_getPrototypeOf(B.prototype), "x", _this11); }; return _asyncToGenerator(regeneratorRuntime.mark(function _callee() { - var f, a, b; + var f, a, b, ref, ref1; return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - var ref, ref1, _args, _args1; + var _args, _args1; f = function() { }, _super_x(), _super_method(), a = _get(_getPrototypeOf(B.prototype), "x", _this6), b = _get(_getPrototypeOf(B.prototype), "x", _this7), _args = f, _set(_getPrototypeOf(B.prototype), "x", _args, _this8, !0), _args1 = f, _set(_getPrototypeOf(B.prototype), "x", _args1, _this9, !0), ref = { f: f }, _super_x1() = ref.f, ref1 = { f: f }, _super_method1() = ref1.f; - case 9: + case 11: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/async/es5/asyncArrowFunction/asyncArrowFunction11_es5/input.ts/es5.1.normal/output.js b/tests/tsc-references/async/es5/asyncArrowFunction/asyncArrowFunction11_es5/input.ts/es5.1.normal/output.js index 01c19d4c354..66b7bb16d4f 100644 --- a/tests/tsc-references/async/es5/asyncArrowFunction/asyncArrowFunction11_es5/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/async/es5/asyncArrowFunction/asyncArrowFunction11_es5/input.ts/es5.1.normal/output.js @@ -55,21 +55,21 @@ var A = function A() { // @downlevelIteration: true // https://github.com/Microsoft/TypeScript/issues/24722 this.b = _asyncToGenerator(regeneratorRuntime.mark(function _callee() { - for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){ - args[_key] = arguments[_key]; - } - var obj; + var _len, args, _key, obj, _args = arguments; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ctx.next = 2; + for(_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++){ + args[_key] = _args[_key]; + } + _ctx.next = 3; return Promise.resolve(); - case 2: + case 3: obj = _defineProperty({ }, "a", function() { return _this; }); // computed property name after `await` triggers case - case 3: + case 4: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/async/es5/asyncArrowFunction/asyncArrowFunction11_es5/input.ts/es5.2.minified/output.js b/tests/tsc-references/async/es5/asyncArrowFunction/asyncArrowFunction11_es5/input.ts/es5.2.minified/output.js index 28052712ed8..de69447230a 100644 --- a/tests/tsc-references/async/es5/asyncArrowFunction/asyncArrowFunction11_es5/input.ts/es5.2.minified/output.js +++ b/tests/tsc-references/async/es5/asyncArrowFunction/asyncArrowFunction11_es5/input.ts/es5.2.minified/output.js @@ -37,17 +37,18 @@ var A = function() { }); }; })(regeneratorRuntime.mark(function _callee() { - for(var obj, _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++)args[_key] = arguments[_key]; + var _len, args, _key, obj, _args = arguments; return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - return _ctx.next = 2, Promise.resolve(); - case 2: + for(_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++)args[_key] = _args[_key]; + return _ctx.next = 3, Promise.resolve(); + case 3: obj = _defineProperty({ }, "a", function() { return _this; }); - case 3: + case 4: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/async/es5/asyncMethodWithSuper_es5/input.ts/es5.1.normal/output.js b/tests/tsc-references/async/es5/asyncMethodWithSuper_es5/input.ts/es5.1.normal/output.js index 5a62ea65771..8765b536e11 100644 --- a/tests/tsc-references/async/es5/asyncMethodWithSuper_es5/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/async/es5/asyncMethodWithSuper_es5/input.ts/es5.1.normal/output.js @@ -300,7 +300,7 @@ var B = /*#__PURE__*/ function(A) { return _get(_getPrototypeOf(B.prototype), "x", _this11); }; return _asyncToGenerator(regeneratorRuntime.mark(function _callee() { - var f, a, b; + var f, a, b, ref, ref1; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: @@ -312,17 +312,17 @@ var B = /*#__PURE__*/ function(A) { b = _super_method2(); _super_x3(f); _super_method3(f); - var ref; + ; // destructuring assign with property access (ref = { f: f }, _super_x4() = ref.f, ref); - var ref1; + ; // destructuring assign with element access (ref1 = { f: f }, _super_method4() = ref1.f, ref1); - case 9: + case 11: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/async/es5/asyncMethodWithSuper_es5/input.ts/es5.2.minified/output.js b/tests/tsc-references/async/es5/asyncMethodWithSuper_es5/input.ts/es5.2.minified/output.js index 0199979d65b..d10648f12c4 100644 --- a/tests/tsc-references/async/es5/asyncMethodWithSuper_es5/input.ts/es5.2.minified/output.js +++ b/tests/tsc-references/async/es5/asyncMethodWithSuper_es5/input.ts/es5.2.minified/output.js @@ -181,18 +181,18 @@ var A = function() { return _get(_getPrototypeOf(B.prototype), "x", _this11); }; return _asyncToGenerator(regeneratorRuntime.mark(function _callee() { - var f, a, b; + var f, a, b, ref, ref1; return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - var ref, ref1, _args, _args1; + var _args, _args1; f = function() { }, _super_x(), _super_method(), a = _get(_getPrototypeOf(B.prototype), "x", _this6), b = _get(_getPrototypeOf(B.prototype), "x", _this7), _args = f, _set(_getPrototypeOf(B.prototype), "x", _args, _this8, !0), _args1 = f, _set(_getPrototypeOf(B.prototype), "x", _args1, _this9, !0), ref = { f: f }, _super_x1() = ref.f, ref1 = { f: f }, _super_method1() = ref1.f; - case 9: + case 11: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/async/es6/asyncMethodWithSuper_es6/input.ts/es5.1.normal/output.js b/tests/tsc-references/async/es6/asyncMethodWithSuper_es6/input.ts/es5.1.normal/output.js index e2c5a440ee9..af3141e8fc4 100644 --- a/tests/tsc-references/async/es6/asyncMethodWithSuper_es6/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/async/es6/asyncMethodWithSuper_es6/input.ts/es5.1.normal/output.js @@ -417,7 +417,7 @@ var B = /*#__PURE__*/ function(A) { ].concat(_toConsumableArray(_args))); }; return _asyncToGenerator(regeneratorRuntime.mark(function _callee1() { - var f, a, b; + var f, a, b, ref, ref1; return regeneratorRuntime.wrap(function _callee$(_ctx1) { while(1)switch(_ctx1.prev = _ctx1.next){ case 0: @@ -429,12 +429,12 @@ var B = /*#__PURE__*/ function(A) { b = _super_method2(); _super_x3(f); _super_method3(f); - var ref; + ; // destructuring assign with property access (ref = { f: f }, _super_x4() = ref.f, ref); - var ref1; + ; // destructuring assign with element access (ref1 = { f: f @@ -471,7 +471,7 @@ var B = /*#__PURE__*/ function(A) { } }, _callee); })); - case 13: + case 15: case "end": return _ctx1.stop(); } @@ -555,14 +555,14 @@ var B = /*#__PURE__*/ function(A) { return _set(_getPrototypeOf(B.prototype), "x", _args, _this21, true); }; return _asyncToGenerator(regeneratorRuntime.mark(function _callee3() { - var f; + var f, ref; return regeneratorRuntime.wrap(function _callee$(_ctx3) { while(1)switch(_ctx3.prev = _ctx3.next){ case 0: f = function() { }; _super_x(f); - var ref; + ; // destructuring assign with property access (ref = { f: f @@ -583,7 +583,7 @@ var B = /*#__PURE__*/ function(A) { } }, _callee); })); - case 5: + case 6: case "end": return _ctx3.stop(); } @@ -667,14 +667,14 @@ var B = /*#__PURE__*/ function(A) { return _set(_getPrototypeOf(B.prototype), "x", _args, _this27, true); }; return _asyncToGenerator(regeneratorRuntime.mark(function _callee5() { - var f; + var f, ref; return regeneratorRuntime.wrap(function _callee$(_ctx5) { while(1)switch(_ctx5.prev = _ctx5.next){ case 0: f = function() { }; _super_method(f); - var ref; + ; // destructuring assign with element access (ref = { f: f @@ -695,7 +695,7 @@ var B = /*#__PURE__*/ function(A) { } }, _callee); })); - case 5: + case 6: case "end": return _ctx5.stop(); } @@ -779,14 +779,14 @@ var B = /*#__PURE__*/ function(A) { return _set(_getPrototypeOf(B.prototype), "x", _args, _this33, true); }; return _wrapAsyncGenerator(regeneratorRuntime.mark(function _callee7() { - var f; + var f, ref; return regeneratorRuntime.wrap(function _callee$(_ctx7) { while(1)switch(_ctx7.prev = _ctx7.next){ case 0: f = function() { }; _super_x(f); - var ref; + ; // destructuring assign with property access (ref = { f: f @@ -807,7 +807,7 @@ var B = /*#__PURE__*/ function(A) { } }, _callee); })); - case 5: + case 6: case "end": return _ctx7.stop(); } @@ -891,14 +891,14 @@ var B = /*#__PURE__*/ function(A) { return _set(_getPrototypeOf(B.prototype), "x", _args, _this39, true); }; return _wrapAsyncGenerator(regeneratorRuntime.mark(function _callee9() { - var f; + var f, ref; return regeneratorRuntime.wrap(function _callee$(_ctx9) { while(1)switch(_ctx9.prev = _ctx9.next){ case 0: f = function() { }; _super_method(f); - var ref; + ; // destructuring assign with element access (ref = { f: f @@ -919,7 +919,7 @@ var B = /*#__PURE__*/ function(A) { } }, _callee); })); - case 5: + case 6: case "end": return _ctx9.stop(); } diff --git a/tests/tsc-references/async/es6/asyncMethodWithSuper_es6/input.ts/es5.2.minified/output.js b/tests/tsc-references/async/es6/asyncMethodWithSuper_es6/input.ts/es5.2.minified/output.js index e496c10464d..73db0654ebb 100644 --- a/tests/tsc-references/async/es6/asyncMethodWithSuper_es6/input.ts/es5.2.minified/output.js +++ b/tests/tsc-references/async/es6/asyncMethodWithSuper_es6/input.ts/es5.2.minified/output.js @@ -259,11 +259,11 @@ var A = function() { ].concat(_toConsumableArray(_args))); }; return _asyncToGenerator(regeneratorRuntime.mark(function _callee1() { - var f, a, b; + var f, a, b, ref, ref1; return regeneratorRuntime.wrap(function(_ctx1) { for(;;)switch(_ctx1.prev = _ctx1.next){ case 0: - var ref, ref1, _args, _args1; + var _args, _args1; f = function() { }, _super_x(), _super_method(), a = _get(_getPrototypeOf(B.prototype), "x", _this6), b = _get(_getPrototypeOf(B.prototype), "x", _this7), _args = f, _set(_getPrototypeOf(B.prototype), "x", _args, _this8, !0), _args1 = f, _set(_getPrototypeOf(B.prototype), "x", _args1, _this9, !0), ref = { f: f @@ -290,7 +290,7 @@ var A = function() { } }, _callee); })); - case 13: + case 15: case "end": return _ctx1.stop(); } @@ -343,11 +343,11 @@ var A = function() { return _get(_getPrototypeOf(B.prototype), "x", _this16); }; return _asyncToGenerator(regeneratorRuntime.mark(function _callee3() { - var f; + var f, ref; return regeneratorRuntime.wrap(function(_ctx3) { for(;;)switch(_ctx3.prev = _ctx3.next){ case 0: - var ref, _args2; + var _args2; _args2 = f = function() { }, _set(_getPrototypeOf(B.prototype), "x", _args2, _this, !0), ref = { f: f @@ -363,7 +363,7 @@ var A = function() { } }, _callee); })); - case 5: + case 6: case "end": return _ctx3.stop(); } @@ -416,11 +416,11 @@ var A = function() { return _get(_getPrototypeOf(B.prototype), "x", _this20); }; return _asyncToGenerator(regeneratorRuntime.mark(function _callee5() { - var f; + var f, ref; return regeneratorRuntime.wrap(function(_ctx5) { for(;;)switch(_ctx5.prev = _ctx5.next){ case 0: - var ref, _args3; + var _args3; _args3 = f = function() { }, _set(_getPrototypeOf(B.prototype), "x", _args3, _this, !0), ref = { f: f @@ -436,7 +436,7 @@ var A = function() { } }, _callee); })); - case 5: + case 6: case "end": return _ctx5.stop(); } @@ -489,11 +489,11 @@ var A = function() { return _get(_getPrototypeOf(B.prototype), "x", _this24); }; return _wrapAsyncGenerator(regeneratorRuntime.mark(function _callee7() { - var f; + var f, ref; return regeneratorRuntime.wrap(function(_ctx7) { for(;;)switch(_ctx7.prev = _ctx7.next){ case 0: - var ref, _args4; + var _args4; _args4 = f = function() { }, _set(_getPrototypeOf(B.prototype), "x", _args4, _this, !0), ref = { f: f @@ -509,7 +509,7 @@ var A = function() { } }, _callee); })); - case 5: + case 6: case "end": return _ctx7.stop(); } @@ -562,11 +562,11 @@ var A = function() { return _get(_getPrototypeOf(B.prototype), "x", _this28); }; return _wrapAsyncGenerator(regeneratorRuntime.mark(function _callee9() { - var f; + var f, ref; return regeneratorRuntime.wrap(function(_ctx9) { for(;;)switch(_ctx9.prev = _ctx9.next){ case 0: - var ref, _args5; + var _args5; _args5 = f = function() { }, _set(_getPrototypeOf(B.prototype), "x", _args5, _this, !0), ref = { f: f @@ -582,7 +582,7 @@ var A = function() { } }, _callee); })); - case 5: + case 6: case "end": return _ctx9.stop(); } diff --git a/tests/tsc-references/async/es6/asyncWithVarShadowing_es6/input.ts/es5.1.normal/output.js b/tests/tsc-references/async/es6/asyncWithVarShadowing_es6/input.ts/es5.1.normal/output.js index f0c870d8de6..1371bbb9e7b 100644 --- a/tests/tsc-references/async/es6/asyncWithVarShadowing_es6/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/async/es6/asyncWithVarShadowing_es6/input.ts/es5.1.normal/output.js @@ -45,6 +45,9 @@ function _extends() { }; return _extends.apply(this, arguments); } +function _iterableToArray(iter) { + if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); +} function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; @@ -73,6 +76,9 @@ function _nonIterableRest() { function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } +function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest(); +} function _fn1() { _fn1 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { var x; @@ -169,8 +175,7 @@ function _fn6() { return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref; - ref = y, x = ref.x, z = ref.z, ref; + x = y.x, z = y.z; case 1: case "end": return _ctx.stop(); @@ -184,12 +189,11 @@ function fn6(x) { } function _fn7() { _fn7 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x; + var _x, x; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref, ref1; - ref = y, ref1 = ref.x, x = ref1 === void 0 ? y : ref1, ref; + _x = y.x, x = _x === void 0 ? y : _x; case 1: case "end": return _ctx.stop(); @@ -207,8 +211,7 @@ function _fn8() { return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref; - ref = y, x = ref.z, ref; + x = y.z; case 1: case "end": return _ctx.stop(); @@ -226,8 +229,7 @@ function _fn9() { return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref; - ref = y, x = ref.z.x, ref; + x = y.z.x; case 1: case "end": return _ctx.stop(); @@ -241,13 +243,11 @@ function fn9(x) { } function _fn10() { _fn10 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x; + var tmp, x; return regeneratorRuntime.wrap(function _callee$(_ctx) { - var ref; while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref2; - ref2 = y, ref = y, x = ref.x, ref2; + tmp = y.z, x = (tmp === void 0 ? y : tmp).x; case 1: case "end": return _ctx.stop(); @@ -280,12 +280,11 @@ function fn11(x) { } function _fn12() { _fn12 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x; + var _y, x; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref; - ref = y, x = ref[0], ref; + _y = _slicedToArray(y, 1), x = _y[0]; case 1: case "end": return _ctx.stop(); @@ -299,12 +298,11 @@ function fn12(x) { } function _fn13() { _fn13 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x; + var _y, tmp, x; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref, ref3; - ref = y, ref3 = ref[0], x = ref3 === void 0 ? y : ref3, ref; + _y = _slicedToArray(y, 1), tmp = _y[0], x = tmp === void 0 ? y : tmp; case 1: case "end": return _ctx.stop(); @@ -318,12 +316,11 @@ function fn13(x) { } function _fn14() { _fn14 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x; + var _y, x; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref; - ref = y, x = ref[1], ref; + _y = _slicedToArray(y, 2), x = _y[1]; case 1: case "end": return _ctx.stop(); @@ -337,12 +334,11 @@ function fn14(x) { } function _fn15() { _fn15 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x; + var _y, x; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref; - ref = y, x = ref.slice(0), ref; + _y = _toArray(y), x = _y.slice(0); case 1: case "end": return _ctx.stop(); @@ -356,12 +352,11 @@ function fn15(x) { } function _fn16() { _fn16 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x; + var _y, ref, x; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref, ref4; - ref = y, ref4 = ref[0], x = ref4[0], ref4, ref; + _y = _slicedToArray(y, 1), ref = _slicedToArray(_y[0], 1), x = ref[0]; case 1: case "end": return _ctx.stop(); @@ -375,12 +370,11 @@ function fn16(x) { } function _fn17() { _fn17 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x; + var _y, tmp, ref, x; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - var ref, ref5, ref6; - ref = y, ref5 = ref[0], ref6 = ref5 === void 0 ? y : ref5, x = ref6[0], ref6, ref; + _y = _slicedToArray(y, 1), tmp = _y[0], ref = _slicedToArray(tmp === void 0 ? y : tmp, 1), x = ref[0]; case 1: case "end": return _ctx.stop(); @@ -394,13 +388,13 @@ function fn17(x) { } function _fn18() { _fn18 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(param) { - var x = param.x; - var x; + var x, x; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: + x = param.x; ; - case 1: + case 2: case "end": return _ctx.stop(); } @@ -413,13 +407,13 @@ function fn18(_) { } function _fn19() { _fn19 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(param) { - var _param = _slicedToArray(param, 1), x = _param[0]; - var x; + var _param, x, x; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: + _param = _slicedToArray(param, 1), x = _param[0]; ; - case 1: + case 2: case "end": return _ctx.stop(); } @@ -556,13 +550,13 @@ function fn25(x) { } function _fn26() { _fn26 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x2; + var x2, x2; return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: try { } catch (param) { - var x2 = param.x; + x2 = param.x; ; } case 1: diff --git a/tests/tsc-references/async/es6/asyncWithVarShadowing_es6/input.ts/es5.2.minified/output.js b/tests/tsc-references/async/es6/asyncWithVarShadowing_es6/input.ts/es5.2.minified/output.js index 5023a73a504..d4b27cddd8d 100644 --- a/tests/tsc-references/async/es6/asyncWithVarShadowing_es6/input.ts/es5.2.minified/output.js +++ b/tests/tsc-references/async/es6/asyncWithVarShadowing_es6/input.ts/es5.2.minified/output.js @@ -1,4 +1,7 @@ import regeneratorRuntime from "regenerator-runtime"; +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg), value = info.value; @@ -32,6 +35,31 @@ function _extends() { return target; }).apply(this, arguments); } +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); +} +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || (function(arr, i) { + var _arr = [], _n = !0, _d = !1, _e = void 0; + try { + for(var _s, _i = arr[Symbol.iterator](); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !i || _arr.length !== i); _n = !0); + } catch (err) { + _d = !0, _e = err; + } finally{ + try { + _n || null == _i.return || _i.return(); + } finally{ + if (_d) throw _e; + } + } + return _arr; + })(arr, i) || _nonIterableRest(); +} +function _toArray(arr) { + return _arrayWithHoles(arr) || (function(iter) { + if (Symbol.iterator in Object(iter) || "[object Arguments]" === Object.prototype.toString.call(iter)) return Array.from(iter); + })(arr) || _nonIterableRest(); +} function _fn1() { return (_fn1 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { return regeneratorRuntime.wrap(function(_ctx) { @@ -102,8 +130,7 @@ function _fn6() { return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - var ref; - x = (ref = y).x, z = ref.z; + x = y.x, z = y.z; case 1: case "end": return _ctx.stop(); @@ -113,12 +140,11 @@ function _fn6() { } function _fn7() { return (_fn7 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x; + var _x, x; return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - var ref; - x = void 0 === (ref = y.x) ? y : ref; + x = void 0 === (_x = y.x) ? y : _x; case 1: case "end": return _ctx.stop(); @@ -156,11 +182,11 @@ function _fn9() { } function _fn10() { return (_fn10 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x; + var tmp, x; return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - x = y.x; + x = (void 0 === (tmp = y.z) ? y : tmp).x; case 1: case "end": return _ctx.stop(); @@ -185,11 +211,11 @@ function _fn11() { } function _fn12() { return (_fn12 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x; + var _y, x; return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - x = y[0]; + x = (_y = _slicedToArray(y, 1))[0]; case 1: case "end": return _ctx.stop(); @@ -199,12 +225,11 @@ function _fn12() { } function _fn13() { return (_fn13 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x; + var _y, tmp, x; return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - var ref; - x = void 0 === (ref = y[0]) ? y : ref; + x = void 0 === (tmp = (_y = _slicedToArray(y, 1))[0]) ? y : tmp; case 1: case "end": return _ctx.stop(); @@ -214,11 +239,11 @@ function _fn13() { } function _fn14() { return (_fn14 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x; + var _y, x; return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - x = y[1]; + x = (_y = _slicedToArray(y, 2))[1]; case 1: case "end": return _ctx.stop(); @@ -228,11 +253,11 @@ function _fn14() { } function _fn15() { return (_fn15 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x; + var _y, x; return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - x = y.slice(0); + x = (_y = _toArray(y)).slice(0); case 1: case "end": return _ctx.stop(); @@ -242,11 +267,11 @@ function _fn15() { } function _fn16() { return (_fn16 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x; + var _y, ref, x; return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - x = y[0][0]; + _y = _slicedToArray(y, 1), ref = _slicedToArray(_y[0], 1), x = ref[0]; case 1: case "end": return _ctx.stop(); @@ -256,12 +281,11 @@ function _fn16() { } function _fn17() { return (_fn17 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { - var x; + var _y, tmp, ref, x; return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - var ref; - x = (void 0 === (ref = y[0]) ? y : ref)[0]; + tmp = (_y = _slicedToArray(y, 1))[0], ref = _slicedToArray(void 0 === tmp ? y : tmp, 1), x = ref[0]; case 1: case "end": return _ctx.stop(); @@ -271,10 +295,12 @@ function _fn17() { } function _fn18() { return (_fn18 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(param) { - return param.x, regeneratorRuntime.wrap(function(_ctx) { + var x, x; + return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - case 1: + x = param.x; + case 2: case "end": return _ctx.stop(); } @@ -283,29 +309,12 @@ function _fn18() { } function _fn19() { return (_fn19 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(param) { - var arr, i; - return (i = 1, (function(arr) { - if (Array.isArray(arr)) return arr; - })(arr = param) || (function(arr, i) { - var _arr = [], _n = !0, _d = !1, _e = void 0; - try { - for(var _s, _i = arr[Symbol.iterator](); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !i || _arr.length !== i); _n = !0); - } catch (err) { - _d = !0, _e = err; - } finally{ - try { - _n || null == _i.return || _i.return(); - } finally{ - if (_d) throw _e; - } - } - return _arr; - })(arr, i) || (function() { - throw new TypeError("Invalid attempt to destructure non-iterable instance"); - })())[0], regeneratorRuntime.wrap(function(_ctx) { + var _param, x, x; + return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - case 1: + x = (_param = _slicedToArray(param, 1))[0]; + case 2: case "end": return _ctx.stop(); } @@ -395,11 +404,13 @@ function _fn25() { } function _fn26() { return (_fn26 = _asyncToGenerator(regeneratorRuntime.mark(function _callee(x) { + var x1, x1; return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: try { } catch (param) { + x1 = param.x; } case 1: case "end": diff --git a/tests/tsc-references/es6/functionDeclarations/FunctionDeclaration9_es6/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/functionDeclarations/FunctionDeclaration9_es6/input.ts/es5.1.normal/output.js index a5785e3aaed..2d31a89433f 100644 --- a/tests/tsc-references/es6/functionDeclarations/FunctionDeclaration9_es6/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/functionDeclarations/FunctionDeclaration9_es6/input.ts/es5.1.normal/output.js @@ -19,10 +19,16 @@ function foo() { return regeneratorRuntime.wrap(function foo$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ctx.t0 = foo; - v = _defineProperty({ - }, (yield), _ctx.t0); - case 2: + _ctx.t0 = _defineProperty; + _ctx.t1 = { + }; + _ctx.next = 4; + return; + case 4: + _ctx.t2 = _ctx.sent; + _ctx.t3 = foo; + v = (0, _ctx.t0)(_ctx.t1, _ctx.t2, _ctx.t3); + case 7: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/es6/functionDeclarations/FunctionDeclaration9_es6/input.ts/es5.2.minified/output.js b/tests/tsc-references/es6/functionDeclarations/FunctionDeclaration9_es6/input.ts/es5.2.minified/output.js index b1bf9049dfe..4d93d4674b3 100644 --- a/tests/tsc-references/es6/functionDeclarations/FunctionDeclaration9_es6/input.ts/es5.2.minified/output.js +++ b/tests/tsc-references/es6/functionDeclarations/FunctionDeclaration9_es6/input.ts/es5.2.minified/output.js @@ -13,9 +13,12 @@ function foo() { return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - _ctx.t0 = foo, v = _defineProperty({ - }, (yield), _ctx.t0); - case 2: + _ctx.t0 = _defineProperty, _ctx.t1 = { + }, _ctx.next = 4; + return; + case 4: + _ctx.t2 = _ctx.sent, _ctx.t3 = foo, v = (0, _ctx.t0)(_ctx.t1, _ctx.t2, _ctx.t3); + case 7: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck41/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck41/input.ts/es5.1.normal/output.js index 28cf58fe5a7..c468b86d727 100644 --- a/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck41/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck41/input.ts/es5.1.normal/output.js @@ -19,9 +19,15 @@ function g() { return regeneratorRuntime.wrap(function g$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - x = _defineProperty({ - }, (yield 0), 0); - case 1: + _ctx.t0 = _defineProperty; + _ctx.t1 = { + }; + _ctx.next = 4; + return 0; + case 4: + _ctx.t2 = _ctx.sent; + x = (0, _ctx.t0)(_ctx.t1, _ctx.t2, 0); + case 6: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck41/input.ts/es5.2.minified/output.js b/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck41/input.ts/es5.2.minified/output.js index 74093b6da38..7f640490c78 100644 --- a/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck41/input.ts/es5.2.minified/output.js +++ b/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck41/input.ts/es5.2.minified/output.js @@ -12,9 +12,11 @@ var _marked = regeneratorRuntime.mark(function() { return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - x = _defineProperty({ - }, (yield 0), 0); - case 1: + return _ctx.t0 = _defineProperty, _ctx.t1 = { + }, _ctx.next = 4, 0; + case 4: + _ctx.t2 = _ctx.sent, x = (0, _ctx.t0)(_ctx.t1, _ctx.t2, 0); + case 6: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck42/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck42/input.ts/es5.1.normal/output.js index 3059ae78326..35b2bc62d0c 100644 --- a/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck42/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck42/input.ts/es5.1.normal/output.js @@ -19,11 +19,17 @@ function g() { return regeneratorRuntime.wrap(function g$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ctx.t0 = function() { + _ctx.t0 = _defineProperty; + _ctx.t1 = { }; - x = _defineProperty({ - }, (yield 0), _ctx.t0); - case 2: + _ctx.next = 4; + return 0; + case 4: + _ctx.t2 = _ctx.sent; + _ctx.t3 = function() { + }; + x = (0, _ctx.t0)(_ctx.t1, _ctx.t2, _ctx.t3); + case 7: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck42/input.ts/es5.2.minified/output.js b/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck42/input.ts/es5.2.minified/output.js index 61c5fe68b06..b03f52c3ea6 100644 --- a/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck42/input.ts/es5.2.minified/output.js +++ b/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck42/input.ts/es5.2.minified/output.js @@ -12,10 +12,12 @@ var _marked = regeneratorRuntime.mark(function() { return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - _ctx.t0 = function() { - }, x = _defineProperty({ - }, (yield 0), _ctx.t0); - case 2: + return _ctx.t0 = _defineProperty, _ctx.t1 = { + }, _ctx.next = 4, 0; + case 4: + _ctx.t2 = _ctx.sent, _ctx.t3 = function() { + }, x = (0, _ctx.t0)(_ctx.t1, _ctx.t2, _ctx.t3); + case 7: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck43/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck43/input.ts/es5.1.normal/output.js index 6985cd603de..800aa929fe1 100644 --- a/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck43/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck43/input.ts/es5.1.normal/output.js @@ -19,7 +19,14 @@ function g() { return regeneratorRuntime.wrap(function g$(_ctx1) { while(1)switch(_ctx1.prev = _ctx1.next){ case 0: - _ctx1.t0 = regeneratorRuntime.mark(function _callee() { + _ctx1.t0 = _defineProperty; + _ctx1.t1 = { + }; + _ctx1.next = 4; + return 0; + case 4: + _ctx1.t2 = _ctx1.sent; + _ctx1.t3 = regeneratorRuntime.mark(function _callee() { return regeneratorRuntime.wrap(function _callee$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: @@ -28,9 +35,8 @@ function g() { } }, _callee); }); - x = _defineProperty({ - }, (yield 0), _ctx1.t0); - case 2: + x = (0, _ctx1.t0)(_ctx1.t1, _ctx1.t2, _ctx1.t3); + case 7: case "end": return _ctx1.stop(); } diff --git a/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck43/input.ts/es5.2.minified/output.js b/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck43/input.ts/es5.2.minified/output.js index 2459a3ccaba..cd34ef65f81 100644 --- a/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck43/input.ts/es5.2.minified/output.js +++ b/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck43/input.ts/es5.2.minified/output.js @@ -12,7 +12,10 @@ var _marked = regeneratorRuntime.mark(function() { return regeneratorRuntime.wrap(function(_ctx1) { for(;;)switch(_ctx1.prev = _ctx1.next){ case 0: - _ctx1.t0 = regeneratorRuntime.mark(function _callee() { + return _ctx1.t0 = _defineProperty, _ctx1.t1 = { + }, _ctx1.next = 4, 0; + case 4: + _ctx1.t2 = _ctx1.sent, _ctx1.t3 = regeneratorRuntime.mark(function _callee() { return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: @@ -20,9 +23,8 @@ var _marked = regeneratorRuntime.mark(function() { return _ctx.stop(); } }, _callee); - }), x = _defineProperty({ - }, (yield 0), _ctx1.t0); - case 2: + }), x = (0, _ctx1.t0)(_ctx1.t1, _ctx1.t2, _ctx1.t3); + case 7: case "end": return _ctx1.stop(); } diff --git a/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck44/input.ts/es5.1.normal/output.js b/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck44/input.ts/es5.1.normal/output.js index 3308cab75c4..7513360f830 100644 --- a/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck44/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck44/input.ts/es5.1.normal/output.js @@ -27,12 +27,35 @@ function g() { return regeneratorRuntime.wrap(function g$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - x = ({ - }, _mutatorMap[yield 0] = _mutatorMap[yield 0] || { - }, _mutatorMap[yield 0].get = function() { + ({ + }); + _ctx.next = 3; + return 0; + case 3: + _ctx.t0 = _ctx.sent; + _ctx.next = 6; + return 0; + case 6: + _ctx.t2 = _ctx.sent; + _ctx.t1 = _mutatorMap[_ctx.t2]; + if (_ctx.t1) { + _ctx.next = 10; + break; + } + _ctx.t1 = { + }; + case 10: + _mutatorMap[_ctx.t0] = _ctx.t1; + _ctx.next = 13; + return 0; + case 13: + _ctx.t3 = _ctx.sent; + _mutatorMap[_ctx.t3].get = function() { return 0; - }, _defineEnumerableProperties(_obj, _mutatorMap), _obj); - case 1: + }; + _defineEnumerableProperties(_obj, _mutatorMap); + x = (0, _obj); + case 17: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck44/input.ts/es5.2.minified/output.js b/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck44/input.ts/es5.2.minified/output.js index e4f1a36c004..47b60d2d866 100644 --- a/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck44/input.ts/es5.2.minified/output.js +++ b/tests/tsc-references/es6/yieldExpressions/generatorTypeCheck44/input.ts/es5.2.minified/output.js @@ -15,11 +15,23 @@ var _obj, _marked = regeneratorRuntime.mark(function() { return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - x = (_mutatorMap[yield 0] = _mutatorMap[yield 0] || { - }, _mutatorMap[yield 0].get = function() { + return _ctx.next = 3, 0; + case 3: + return _ctx.t0 = _ctx.sent, _ctx.next = 6, 0; + case 6: + if (_ctx.t2 = _ctx.sent, _ctx.t1 = _mutatorMap[_ctx.t2], _ctx.t1) { + _ctx.next = 10; + break; + } + _ctx.t1 = { + }; + case 10: + return _mutatorMap[_ctx.t0] = _ctx.t1, _ctx.next = 13, 0; + case 13: + _ctx.t3 = _ctx.sent, _mutatorMap[_ctx.t3].get = function() { return 0; - }, _defineEnumerableProperties(_obj, _mutatorMap), _obj); - case 1: + }, _defineEnumerableProperties(_obj, _mutatorMap), x = _obj; + case 17: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/generators/generatorReturnTypeInference/input.ts/es5.1.normal/output.js b/tests/tsc-references/generators/generatorReturnTypeInference/input.ts/es5.1.normal/output.js index 70de1fc7366..44b2082128c 100644 --- a/tests/tsc-references/generators/generatorReturnTypeInference/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/generators/generatorReturnTypeInference/input.ts/es5.1.normal/output.js @@ -1,4 +1,35 @@ import regeneratorRuntime from "regenerator-runtime"; +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} +function _iterableToArrayLimit(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + try { + for(var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true){ + _arr.push(_s.value); + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally{ + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally{ + if (_d) throw _e; + } + } + return _arr; +} +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); +} +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); +} var _marked = regeneratorRuntime.mark(g311); var _marked1 = regeneratorRuntime.mark(g310); var _marked2 = regeneratorRuntime.mark(g309); @@ -380,16 +411,21 @@ function g309(x, y) { }, _marked2); } function g310() { - var a, b; + var ref, tmp, a, tmp1, b; return regeneratorRuntime.wrap(function g310$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ctx.next = 2; + _ctx.t0 = _slicedToArray; + _ctx.next = 3; return; - case 2: - var ref, ref1, ref2; - ref = _ctx.sent, ref1 = ref[0], a = ref1 === void 0 ? 1 : ref1, ref2 = ref[1], b = ref2 === void 0 ? 2 : ref2, ref; case 3: + _ctx.t1 = _ctx.sent; + ref = (0, _ctx.t0)(_ctx.t1, 2); + tmp = ref[0]; + a = tmp === void 0 ? 1 : tmp; + tmp1 = ref[1]; + b = tmp1 === void 0 ? 2 : tmp1; + case 9: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/generators/generatorReturnTypeInference/input.ts/es5.2.minified/output.js b/tests/tsc-references/generators/generatorReturnTypeInference/input.ts/es5.2.minified/output.js index 8b253f34546..3eb60b157d2 100644 --- a/tests/tsc-references/generators/generatorReturnTypeInference/input.ts/es5.2.minified/output.js +++ b/tests/tsc-references/generators/generatorReturnTypeInference/input.ts/es5.2.minified/output.js @@ -1,4 +1,25 @@ import regeneratorRuntime from "regenerator-runtime"; +function _slicedToArray(arr, i) { + return (function(arr) { + if (Array.isArray(arr)) return arr; + })(arr) || (function(arr, i) { + var _arr = [], _n = !0, _d = !1, _e = void 0; + try { + for(var _s, _i = arr[Symbol.iterator](); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !i || _arr.length !== i); _n = !0); + } catch (err) { + _d = !0, _e = err; + } finally{ + try { + _n || null == _i.return || _i.return(); + } finally{ + if (_d) throw _e; + } + } + return _arr; + })(arr, i) || (function() { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + })(); +} var _marked = regeneratorRuntime.mark(function() { return regeneratorRuntime.wrap(function(_ctx1) { for(;;)switch(_ctx1.prev = _ctx1.next){ @@ -24,16 +45,15 @@ var _marked = regeneratorRuntime.mark(function() { } }, _marked); }), _marked1 = regeneratorRuntime.mark(function() { - var a, b; + var ref, tmp, a, tmp1, b; return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - _ctx.next = 2; + _ctx.t0 = _slicedToArray, _ctx.next = 3; return; - case 2: - var ref, ref1, ref2; - a = void 0 === (ref1 = (ref = _ctx.sent)[0]) ? 1 : ref1, ref2 = ref[1], b = void 0 === ref2 ? 2 : ref2; case 3: + _ctx.t1 = _ctx.sent, a = void 0 === (tmp = (ref = (0, _ctx.t0)(_ctx.t1, 2))[0]) ? 1 : tmp, tmp1 = ref[1], b = void 0 === tmp1 ? 2 : tmp1; + case 9: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/generators/generatorReturnTypeInferenceNonStrict/input.ts/es5.1.normal/output.js b/tests/tsc-references/generators/generatorReturnTypeInferenceNonStrict/input.ts/es5.1.normal/output.js index 1ac5af4c8f6..a8c810bf171 100644 --- a/tests/tsc-references/generators/generatorReturnTypeInferenceNonStrict/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/generators/generatorReturnTypeInferenceNonStrict/input.ts/es5.1.normal/output.js @@ -1,4 +1,35 @@ import regeneratorRuntime from "regenerator-runtime"; +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} +function _iterableToArrayLimit(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + try { + for(var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true){ + _arr.push(_s.value); + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally{ + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally{ + if (_d) throw _e; + } + } + return _arr; +} +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); +} +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); +} var _marked = regeneratorRuntime.mark(g311); var _marked1 = regeneratorRuntime.mark(g310); var _marked2 = regeneratorRuntime.mark(g309); @@ -382,16 +413,21 @@ function g309(x, y) { }, _marked2); } function g310() { - var a, b; + var ref, tmp, a, tmp1, b; return regeneratorRuntime.wrap(function g310$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: - _ctx.next = 2; + _ctx.t0 = _slicedToArray; + _ctx.next = 3; return; - case 2: - var ref, ref1, ref2; - ref = _ctx.sent, ref1 = ref[0], a = ref1 === void 0 ? 1 : ref1, ref2 = ref[1], b = ref2 === void 0 ? 2 : ref2, ref; case 3: + _ctx.t1 = _ctx.sent; + ref = (0, _ctx.t0)(_ctx.t1, 2); + tmp = ref[0]; + a = tmp === void 0 ? 1 : tmp; + tmp1 = ref[1]; + b = tmp1 === void 0 ? 2 : tmp1; + case 9: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/generators/generatorReturnTypeInferenceNonStrict/input.ts/es5.2.minified/output.js b/tests/tsc-references/generators/generatorReturnTypeInferenceNonStrict/input.ts/es5.2.minified/output.js index 8b253f34546..3eb60b157d2 100644 --- a/tests/tsc-references/generators/generatorReturnTypeInferenceNonStrict/input.ts/es5.2.minified/output.js +++ b/tests/tsc-references/generators/generatorReturnTypeInferenceNonStrict/input.ts/es5.2.minified/output.js @@ -1,4 +1,25 @@ import regeneratorRuntime from "regenerator-runtime"; +function _slicedToArray(arr, i) { + return (function(arr) { + if (Array.isArray(arr)) return arr; + })(arr) || (function(arr, i) { + var _arr = [], _n = !0, _d = !1, _e = void 0; + try { + for(var _s, _i = arr[Symbol.iterator](); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !i || _arr.length !== i); _n = !0); + } catch (err) { + _d = !0, _e = err; + } finally{ + try { + _n || null == _i.return || _i.return(); + } finally{ + if (_d) throw _e; + } + } + return _arr; + })(arr, i) || (function() { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + })(); +} var _marked = regeneratorRuntime.mark(function() { return regeneratorRuntime.wrap(function(_ctx1) { for(;;)switch(_ctx1.prev = _ctx1.next){ @@ -24,16 +45,15 @@ var _marked = regeneratorRuntime.mark(function() { } }, _marked); }), _marked1 = regeneratorRuntime.mark(function() { - var a, b; + var ref, tmp, a, tmp1, b; return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - _ctx.next = 2; + _ctx.t0 = _slicedToArray, _ctx.next = 3; return; - case 2: - var ref, ref1, ref2; - a = void 0 === (ref1 = (ref = _ctx.sent)[0]) ? 1 : ref1, ref2 = ref[1], b = void 0 === ref2 ? 2 : ref2; case 3: + _ctx.t1 = _ctx.sent, a = void 0 === (tmp = (ref = (0, _ctx.t0)(_ctx.t1, 2))[0]) ? 1 : tmp, tmp1 = ref[1], b = void 0 === tmp1 ? 2 : tmp1; + case 9: case "end": return _ctx.stop(); } diff --git a/tests/tsc-references/generators/restParameterInDownlevelGenerator/input.ts/es5.1.normal/output.js b/tests/tsc-references/generators/restParameterInDownlevelGenerator/input.ts/es5.1.normal/output.js index e992221499a..8224c3123ec 100644 --- a/tests/tsc-references/generators/restParameterInDownlevelGenerator/input.ts/es5.1.normal/output.js +++ b/tests/tsc-references/generators/restParameterInDownlevelGenerator/input.ts/es5.1.normal/output.js @@ -6,59 +6,59 @@ var _marked = regeneratorRuntime.mark(mergeStringLists); // @noEmitHelpers: true // https://github.com/Microsoft/TypeScript/issues/30653 function mergeStringLists() { - for(var _len = arguments.length, strings = new Array(_len), _key = 0; _key < _len; _key++){ - strings[_key] = arguments[_key]; - } - var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, str; + var _len, strings, _key, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, str, _args = arguments; return regeneratorRuntime.wrap(function mergeStringLists$(_ctx) { while(1)switch(_ctx.prev = _ctx.next){ case 0: + for(_len = _args.length, strings = new Array(_len), _key = 0; _key < _len; _key++){ + strings[_key] = _args[_key]; + } _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; - _ctx.prev = 1; + _ctx.prev = 2; for(_iterator = strings[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ str = _step.value; ; } - _ctx.next = 9; + _ctx.next = 10; break; - case 5: - _ctx.prev = 5; - _ctx.t0 = _ctx["catch"](1); + case 6: + _ctx.prev = 6; + _ctx.t0 = _ctx["catch"](2); _didIteratorError = true; _iteratorError = _ctx.t0; - case 9: - _ctx.prev = 9; + case 10: _ctx.prev = 10; + _ctx.prev = 11; if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } - case 12: - _ctx.prev = 12; + case 13: + _ctx.prev = 13; if (!_didIteratorError) { - _ctx.next = 15; + _ctx.next = 16; break; } throw _iteratorError; - case 15: - return _ctx.finish(12); case 16: - return _ctx.finish(9); + return _ctx.finish(13); case 17: + return _ctx.finish(10); + case 18: case "end": return _ctx.stop(); } }, _marked, null, [ [ - 1, - 5, - 9, - 17 + 2, + 6, + 10, + 18 ], [ - 10, + 11, , - 12, - 16 + 13, + 17 ] ]); } diff --git a/tests/tsc-references/generators/restParameterInDownlevelGenerator/input.ts/es5.2.minified/output.js b/tests/tsc-references/generators/restParameterInDownlevelGenerator/input.ts/es5.2.minified/output.js index f20cf91b2c3..5979af2889d 100644 --- a/tests/tsc-references/generators/restParameterInDownlevelGenerator/input.ts/es5.2.minified/output.js +++ b/tests/tsc-references/generators/restParameterInDownlevelGenerator/input.ts/es5.2.minified/output.js @@ -1,42 +1,43 @@ import regeneratorRuntime from "regenerator-runtime"; var _marked = regeneratorRuntime.mark(function() { - for(var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, str, _len = arguments.length, strings = new Array(_len), _key = 0; _key < _len; _key++)strings[_key] = arguments[_key]; + var _len, strings, _key, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, str, _args = arguments; return regeneratorRuntime.wrap(function(_ctx) { for(;;)switch(_ctx.prev = _ctx.next){ case 0: - for(_iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0, _ctx.prev = 1, _iterator = strings[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)str = _step.value; - _ctx.next = 9; + for(_len = _args.length, strings = new Array(_len), _key = 0; _key < _len; _key++)strings[_key] = _args[_key]; + for(_iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0, _ctx.prev = 2, _iterator = strings[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)str = _step.value; + _ctx.next = 10; break; - case 5: - _ctx.prev = 5, _ctx.t0 = _ctx.catch(1), _didIteratorError = !0, _iteratorError = _ctx.t0; - case 9: - _ctx.prev = 9, _ctx.prev = 10, _iteratorNormalCompletion || null == _iterator.return || _iterator.return(); - case 12: - if (_ctx.prev = 12, !_didIteratorError) { - _ctx.next = 15; + case 6: + _ctx.prev = 6, _ctx.t0 = _ctx.catch(2), _didIteratorError = !0, _iteratorError = _ctx.t0; + case 10: + _ctx.prev = 10, _ctx.prev = 11, _iteratorNormalCompletion || null == _iterator.return || _iterator.return(); + case 13: + if (_ctx.prev = 13, !_didIteratorError) { + _ctx.next = 16; break; } throw _iteratorError; - case 15: - return _ctx.finish(12); case 16: - return _ctx.finish(9); + return _ctx.finish(13); case 17: + return _ctx.finish(10); + case 18: case "end": return _ctx.stop(); } }, _marked, null, [ [ - 1, - 5, - 9, - 17 + 2, + 6, + 10, + 18 ], [ - 10, + 11, , - 12, - 16 + 13, + 17 ] ]); });