From 7840c5469d05e70213c7b71f3f94c6f5f25f1f65 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Mon, 8 Jan 2024 19:06:48 +0800 Subject: [PATCH] Improve output of `super()` (#16194) --- .prettierrc | 35 ++--- eslint.config.js | 2 + .../babel-helpers/scripts/generate-helpers.js | 1 + .../babel-helpers/src/helpers-generated.ts | 15 ++ packages/babel-helpers/src/helpers.ts | 137 ++++++------------ .../src/helpers/AsyncGenerator.js | 2 +- .../babel-helpers/src/helpers/applyDecs.js | 36 ++--- .../src/helpers/applyDecs2203.js | 22 +-- .../src/helpers/applyDecs2203R.js | 24 +-- .../src/helpers/applyDecs2301.js | 30 ++-- .../babel-helpers/src/helpers/callSuper.ts | 29 ++++ .../babel-helpers/src/helpers/construct.ts | 24 +++ .../src/helpers/importDeferProxy.js | 2 +- .../src/helpers/isNativeReflectConstruct.ts | 19 +++ .../src/helpers/objectSpread2.js | 2 +- packages/babel-helpers/src/helpers/using.js | 2 +- .../babel-helpers/src/helpers/wrapRegExp.js | 2 +- .../fixtures/legacy-regression/7030/output.js | 3 +- .../foobar/output.js | 3 +- .../super-call-in-decorator/output.js | 3 +- .../nested-class/super-call-in-key/output.js | 3 +- .../super-property-in-accessor-key/output.js | 3 +- .../super-property-in-decorator/output.js | 3 +- .../super-property-in-key/output.js | 3 +- .../derived-multiple-supers/output.js | 5 +- .../fixtures/private-loose/derived/output.js | 3 +- .../fixtures/private-loose/foobar/output.js | 3 +- .../output.js | 3 +- .../nested-class-extends-computed/output.js | 3 +- .../private-in-derived/output.js | 3 +- .../private-loose/super-expression/output.js | 3 +- .../private-loose/super-statement/output.js | 3 +- .../private/derived-multiple-supers/output.js | 5 +- .../test/fixtures/private/derived/output.js | 3 +- .../test/fixtures/private/foobar/output.js | 3 +- .../output.js | 3 +- .../nested-class-extends-computed/output.js | 3 +- .../private/private-in-derived/output.js | 3 +- .../fixtures/private/super-call/output.js | 3 +- .../private/super-expression/output.js | 3 +- .../private/super-statement/output.js | 3 +- .../fixtures/public-loose/derived/output.js | 3 +- .../fixtures/public-loose/foobar/output.js | 3 +- .../public-loose/regression-T6719/output.js | 3 +- .../public-loose/static-super/output.js | 3 +- .../public-loose/super-call/output.js | 3 +- .../public-loose/super-expression/output.js | 3 +- .../public-loose/super-statement/output.js | 3 +- .../public/derived-multiple-supers/output.js | 5 +- .../test/fixtures/public/derived/output.js | 3 +- .../test/fixtures/public/foobar/output.js | 3 +- .../public/regression-T6719/output.js | 3 +- .../fixtures/public/static-super/output.js | 3 +- .../test/fixtures/public/super-call/output.js | 3 +- .../public/super-expression/output.js | 3 +- .../fixtures/public/super-statement/output.js | 3 +- .../test/fixtures/regression/6154/output.js | 3 +- .../test/fixtures/regression/T6719/output.js | 3 +- .../package.json | 1 - ...helpers.ts => inline-callSuper-helpers.ts} | 45 +++--- .../src/transformClass.ts | 61 ++++---- .../accessing-super-class/output.js | 7 +- .../accessing-super-properties/output.js | 3 +- .../calling-super-properties/output.js | 3 +- .../with-superClass/output.js | 3 +- .../extend-builtins/shadowed/output.js | 3 +- .../fixtures/extend-builtins/spec/output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../get-set/memoized-assign/output.js | 3 +- .../get-set/memoized-update/output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../test/fixtures/regression/14652/output.js | 3 +- .../test/fixtures/regression/2663/output.js | 3 +- .../test/fixtures/regression/2694/output.js | 3 +- .../test/fixtures/regression/2775/output.js | 3 +- .../test/fixtures/regression/3028/output.js | 6 +- .../test/fixtures/regression/5769/output.js | 3 +- .../test/fixtures/regression/5817/output.js | 3 +- .../test/fixtures/regression/8499/output.js | 3 +- .../test/fixtures/regression/T2494/output.js | 3 +- .../test/fixtures/regression/T2997/output.js | 3 +- .../test/fixtures/regression/T7537/output.js | 3 +- .../regression/regression-1155/output.js | 3 +- .../spec/accessing-super-class/output.js | 7 +- .../spec/accessing-super-properties/output.js | 3 +- .../output.js | 1 - .../spec/calling-super-properties/output.js | 3 +- .../spec/computed-keys-yield-await/output.js | 3 +- .../test/fixtures/spec/constructor/output.js | 3 +- .../output.js | 5 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 1 - .../output.js | 3 +- .../output.js | 1 - .../output.js | 1 - .../spec/export-super-class/output.mjs | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../nested-class-super-call-in-key/output.js | 3 +- .../output.js | 3 +- .../nested-object-super-call-in-key/output.js | 3 +- .../output.js | 3 +- .../spec/super-class-anonymous/output.js | 15 +- .../output.js | 6 +- .../test/fixtures/spec/super-class/output.js | 3 +- .../exec.js | 22 +++ .../options.json | 9 ++ .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../fixtures/spec/super-spread-args/exec.js | 22 +++ .../output.js | 3 +- .../output.js | 3 +- .../output.js | 3 +- .../output.js | 1 - .../output.js | 3 +- .../function-name/modules-3/output.js | 3 +- .../parameters/rest-nested-iife/output.js | 3 +- .../regression/6057-expanded/output.js | 3 +- .../output.mjs | 3 +- .../output.js | 3 +- .../test/fixtures/regression/12863/output.mjs | 11 +- .../corejs-useESModules/output.mjs | 9 +- .../useESModules-cjs-auto/output.js | 5 +- .../use-options/useESModules-cjs/output.js | 5 +- .../useESModules-mjs-auto/output.mjs | 9 +- .../use-options/useESModules-mjs/output.mjs | 9 +- .../super-classes-plugin-after/output.js | 3 +- .../super-classes-plugin-before/output.js | 3 +- .../output.js | 3 +- .../plugins-integration/issue-7527/output.js | 3 +- .../spread-super-firefox-40/output.js | 3 +- packages/babel-runtime-corejs2/package.json | 45 +++--- packages/babel-runtime-corejs3/package.json | 45 +++--- packages/babel-runtime/package.json | 45 +++--- yarn.lock | 1 - 154 files changed, 555 insertions(+), 560 deletions(-) create mode 100644 packages/babel-helpers/src/helpers/callSuper.ts create mode 100644 packages/babel-helpers/src/helpers/construct.ts create mode 100644 packages/babel-helpers/src/helpers/isNativeReflectConstruct.ts rename packages/babel-plugin-transform-classes/src/{inline-createSuper-helpers.ts => inline-callSuper-helpers.ts} (63%) create mode 100644 packages/babel-plugin-transform-classes/test/fixtures/spec/super-correct-new-target-without-reflect/exec.js create mode 100644 packages/babel-plugin-transform-classes/test/fixtures/spec/super-correct-new-target-without-reflect/options.json create mode 100644 packages/babel-plugin-transform-classes/test/fixtures/spec/super-spread-args/exec.js diff --git a/.prettierrc b/.prettierrc index 2e9e64695a2c..46656f04e11e 100644 --- a/.prettierrc +++ b/.prettierrc @@ -8,25 +8,20 @@ "bracketSameLine": false, "tabWidth": 2, "printWidth": 80, - "overrides": [{ - "files": [ - "**/{codemods,eslint,packages}/*/{src,test}/**/*.{js,ts,cjs}" - ], - "excludeFiles": ["**/packages/babel-helpers/src/helpers/**/*.js"], - "options": { - "trailingComma": "all" + "overrides": [ + { + "files": [ + "**/{codemods,eslint,packages}/*/{src,test}/**/*.{js,cjs,mjs,ts,cts,mts}" + ], + "options": { + "trailingComma": "all" + } + }, + { + "files": ["**/{codemods,eslint,packages}/*/test/fixtures/**/*.{js,ts}"], + "options": { + "trailingComma": "es5" + } } - }, { - "files": "**/packages/babel-helpers/src/helpers/**/*.js", - "options": { - "trailingComma": "es5" - } - }, { - "files": [ - "**/{codemods,eslint,packages}/*/test/fixtures/**/*.{js,ts}" - ], - "options": { - "trailingComma": "es5" - } - }] + ] } diff --git a/eslint.config.js b/eslint.config.js index c0bdca634f3d..97adfe1799c3 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -272,8 +272,10 @@ module.exports = [ "no-var": "off", "comma-dangle": "off", "no-func-assign": "off", + "prefer-spread": "off", "import/no-extraneous-dependencies": "off", "import/no-unresolved": "off", + "@typescript-eslint/prefer-optional-chain": "off", }, }, { diff --git a/packages/babel-helpers/scripts/generate-helpers.js b/packages/babel-helpers/scripts/generate-helpers.js index b9d1e5f11697..0c93a85dec7a 100644 --- a/packages/babel-helpers/scripts/generate-helpers.js +++ b/packages/babel-helpers/scripts/generate-helpers.js @@ -96,6 +96,7 @@ export default Object.freeze({ }).code; code = ( await minify(code, { + ecma: 5, mangle: { keep_fnames: mangleFns ? new RegExp(noMangleFns.join("|")) : true, }, diff --git a/packages/babel-helpers/src/helpers-generated.ts b/packages/babel-helpers/src/helpers-generated.ts index d4fbef00c070..bcb3d3f1a3a3 100644 --- a/packages/babel-helpers/src/helpers-generated.ts +++ b/packages/babel-helpers/src/helpers-generated.ts @@ -63,11 +63,21 @@ export default Object.freeze({ "7.0.0-beta.0", 'import OverloadYield from"OverloadYield";export default function _awaitAsyncGenerator(e){return new OverloadYield(e,0)}', ), + // size: 366, gzip size: 187 + callSuper: helper( + "7.23.8", + 'import getPrototypeOf from"getPrototypeOf";import isNativeReflectConstruct from"isNativeReflectConstruct";import possibleConstructorReturn from"possibleConstructorReturn";export default function _callSuper(t,o,e){return o=getPrototypeOf(o),possibleConstructorReturn(t,isNativeReflectConstruct()?Reflect.construct(o,e||[],getPrototypeOf(t).constructor):o.apply(t,e))}', + ), // size: 161, gzip size: 154 checkInRHS: helper( "7.20.5", 'export default function _checkInRHS(e){if(Object(e)!==e)throw TypeError("right-hand side of \'in\' should be an object, got "+(null!==e?typeof e:"null"));return e}', ), + // size: 327, gzip size: 200 + construct: helper( + "7.0.0-beta.0", + 'import setPrototypeOf from"setPrototypeOf";import isNativeReflectConstruct from"isNativeReflectConstruct";export default function _construct(t,e,r){if(isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var p=new(t.bind.apply(t,o));return r&&setPrototypeOf(p,r.prototype),p}', + ), // size: 130, gzip size: 130 defineAccessor: helper( "7.20.7", @@ -88,6 +98,11 @@ export default Object.freeze({ "7.14.0", 'function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap,t=new WeakMap;return(_getRequireWildcardCache=function(e){return e?t:r})(e)}export default function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u]}return n.default=e,t&&t.set(e,n),n}', ), + // size: 208, gzip size: 154 + isNativeReflectConstruct: helper( + "7.9.0", + "export default function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(_isNativeReflectConstruct=function(){return!!t})()}", + ), // size: 431, gzip size: 303 iterableToArrayLimit: helper( "7.0.0-beta.0", diff --git a/packages/babel-helpers/src/helpers.ts b/packages/babel-helpers/src/helpers.ts index 07208d7ab6d2..b25c7b92b168 100644 --- a/packages/babel-helpers/src/helpers.ts +++ b/packages/babel-helpers/src/helpers.ts @@ -97,31 +97,33 @@ helpers.createClass = helper("7.0.0-beta.0")` } `; -helpers.defineEnumerableProperties = helper("7.0.0-beta.0")` - export default function _defineEnumerableProperties(obj, descs) { - for (var key in descs) { - var desc = descs[key]; - desc.configurable = desc.enumerable = true; - if ("value" in desc) desc.writable = true; - Object.defineProperty(obj, key, desc); - } - - // Symbols are not enumerated over by for-in loops. If native - // Symbols are available, fetch all of the descs object's own - // symbol properties and define them on our target object too. - if (Object.getOwnPropertySymbols) { - var objectSymbols = Object.getOwnPropertySymbols(descs); - for (var i = 0; i < objectSymbols.length; i++) { - var sym = objectSymbols[i]; - var desc = descs[sym]; +if (!process.env.BABEL_8_BREAKING) { + helpers.defineEnumerableProperties = helper("7.0.0-beta.0")` + export default function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; desc.configurable = desc.enumerable = true; if ("value" in desc) desc.writable = true; - Object.defineProperty(obj, sym, desc); + Object.defineProperty(obj, key, desc); + } + + // Symbols are not enumerated over by for-in loops. If native + // Symbols are available, fetch all of the descs object's own + // symbol properties and define them on our target object too. + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } } + return obj; } - return obj; - } `; +} helpers.defaults = helper("7.0.0-beta.0")` export default function _defaults(obj, defaults) { @@ -257,60 +259,6 @@ helpers.setPrototypeOf = helper("7.0.0-beta.0")` } `; -helpers.isNativeReflectConstruct = helper("7.9.0")` - export default function _isNativeReflectConstruct() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - - // core-js@3 - if (Reflect.construct.sham) return false; - - // Proxy can't be polyfilled. Every browser implemented - // proxies before or at the same time as Reflect.construct, - // so if they support Proxy they also support Reflect.construct. - if (typeof Proxy === "function") return true; - - // Since Reflect.construct can't be properly polyfilled, some - // implementations (e.g. core-js@2) don't set the correct internal slots. - // Those polyfills don't allow us to subclass built-ins, so we need to - // use our fallback implementation. - try { - // If the internal slots aren't set, this throws an error similar to - // TypeError: this is not a Boolean object. - - Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})); - return true; - } catch (e) { - return false; - } - } -`; - -// need a bind because https://github.com/babel/babel/issues/14527 -helpers.construct = helper("7.0.0-beta.0")` - import setPrototypeOf from "setPrototypeOf"; - import isNativeReflectConstruct from "isNativeReflectConstruct"; - - export default function _construct(Parent, args, Class) { - if (isNativeReflectConstruct()) { - _construct = Reflect.construct.bind(); - } else { - // NOTE: If Parent !== Class, the correct __proto__ is set *after* - // calling the constructor. - _construct = function _construct(Parent, args, Class) { - var a = [null]; - a.push.apply(a, args); - var Constructor = Function.bind.apply(Parent, a); - var instance = new Constructor(); - if (Class) setPrototypeOf(instance, Class.prototype); - return instance; - }; - } - // Avoid issues with Class being present but undefined when it wasn't - // present in the original call. - return _construct.apply(null, arguments); - } -`; - helpers.isNativeFunction = helper("7.0.0-beta.0")` export default function _isNativeFunction(fn) { // Note: This function returns "true" for core-js functions. @@ -455,28 +403,29 @@ helpers.possibleConstructorReturn = helper("7.0.0-beta.0")` } `; -// This is duplicated to packages/babel-plugin-transform-classes/src/inline-createSuper-helpers.js -helpers.createSuper = helper("7.9.0")` - import getPrototypeOf from "getPrototypeOf"; - import isNativeReflectConstruct from "isNativeReflectConstruct"; - import possibleConstructorReturn from "possibleConstructorReturn"; - - export default function _createSuper(Derived) { - var hasNativeReflectConstruct = isNativeReflectConstruct(); - - return function _createSuperInternal() { - var Super = getPrototypeOf(Derived), result; - if (hasNativeReflectConstruct) { - // NOTE: This doesn't work if this.__proto__.constructor has been modified. - var NewTarget = getPrototypeOf(this).constructor; - result = Reflect.construct(Super, arguments, NewTarget); - } else { - result = Super.apply(this, arguments); +if (!process.env.BABEL_8_BREAKING) { + helpers.createSuper = helper("7.9.0")` + import getPrototypeOf from "getPrototypeOf"; + import isNativeReflectConstruct from "isNativeReflectConstruct"; + import possibleConstructorReturn from "possibleConstructorReturn"; + + export default function _createSuper(Derived) { + var hasNativeReflectConstruct = isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = getPrototypeOf(Derived), result; + if (hasNativeReflectConstruct) { + // NOTE: This doesn't work if this.__proto__.constructor has been modified. + var NewTarget = getPrototypeOf(this).constructor; + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + return possibleConstructorReturn(this, result); } - return possibleConstructorReturn(this, result); } - } - `; +`; +} helpers.superPropBase = helper("7.0.0-beta.0")` import getPrototypeOf from "getPrototypeOf"; diff --git a/packages/babel-helpers/src/helpers/AsyncGenerator.js b/packages/babel-helpers/src/helpers/AsyncGenerator.js index da2a242337f3..b735f9653f39 100644 --- a/packages/babel-helpers/src/helpers/AsyncGenerator.js +++ b/packages/babel-helpers/src/helpers/AsyncGenerator.js @@ -59,7 +59,7 @@ export default function AsyncGenerator(gen) { }, function (err) { resume("throw", err); - } + }, ); } catch (err) { settle("throw", err); diff --git a/packages/babel-helpers/src/helpers/applyDecs.js b/packages/babel-helpers/src/helpers/applyDecs.js index c8acb4e0aaef..22c9e1c2ed21 100644 --- a/packages/babel-helpers/src/helpers/applyDecs.js +++ b/packages/babel-helpers/src/helpers/applyDecs.js @@ -29,7 +29,7 @@ function old_createMetadataMethodsForProperty( metadataMap, kind, property, - decoratorFinishedRef + decoratorFinishedRef, ) { return { getMetadata: function (key) { @@ -147,7 +147,7 @@ function old_memberDec( kind, isStatic, isPrivate, - value + value, ) { var kindStr; @@ -180,7 +180,7 @@ function old_memberDec( if (kind !== 0 /* FIELD */) { ctx.addInitializer = old_createAddInitializerMethod( initializers, - decoratorFinishedRef + decoratorFinishedRef, ); } @@ -229,9 +229,9 @@ function old_memberDec( metadataMap, metadataKind, metadataName, - decoratorFinishedRef - ) - ) + decoratorFinishedRef, + ), + ), ); } finally { decoratorFinishedRef.v = true; @@ -241,7 +241,7 @@ function old_memberDec( function old_assertNotFinished(decoratorFinishedRef, fnName) { if (decoratorFinishedRef.v) { throw new Error( - "attempted to call " + fnName + " after decoration was finished" + "attempted to call " + fnName + " after decoration was finished", ); } } @@ -264,7 +264,7 @@ function old_assertValidReturnValue(kind, value) { if (kind === 1 /* ACCESSOR */) { if (type !== "object" || value === null) { throw new TypeError( - "accessor decorators must return an object with get, set, or init properties or void 0" + "accessor decorators must return an object with get, set, or init properties or void 0", ); } if (value.get !== undefined) { @@ -313,7 +313,7 @@ function old_applyMemberDec( isStatic, isPrivate, metadataMap, - initializers + initializers, ) { var decs = decInfo[0]; @@ -376,7 +376,7 @@ function old_applyMemberDec( kind, isStatic, isPrivate, - value + value, ); if (newValue !== void 0) { @@ -407,7 +407,7 @@ function old_applyMemberDec( kind, isStatic, isPrivate, - value + value, ); if (newValue !== void 0) { @@ -506,7 +506,7 @@ function old_applyMemberDecs( Class, protoMetadataMap, staticMetadataMap, - decInfos + decInfos, ) { var protoInitializers; var staticInitializers; @@ -562,7 +562,7 @@ function old_applyMemberDecs( ) { throw new Error( "Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + - name + name, ); } else if (!existingKind && kind > 2 /* METHOD */) { existingNonFields.set(name, kind); @@ -580,7 +580,7 @@ function old_applyMemberDecs( isStatic, isPrivate, metadataMap, - initializers + initializers, ); } @@ -615,15 +615,15 @@ function old_applyClassDecs(ret, targetClass, metadataMap, classDecs) { name: name, addInitializer: old_createAddInitializerMethod( initializers, - decoratorFinishedRef + decoratorFinishedRef, ), }, old_createMetadataMethodsForProperty( metadataMap, 0 /* CONSTRUCTOR */, name, - decoratorFinishedRef - ) + decoratorFinishedRef, + ), ); var nextNewClass = classDecs[i](newClass, ctx); } finally { @@ -800,7 +800,7 @@ export default function applyDecs(targetClass, memberDecs, classDecs) { targetClass, protoMetadataMap, staticMetadataMap, - memberDecs + memberDecs, ); old_convertMetadataMapToFinal(targetClass.prototype, protoMetadataMap); diff --git a/packages/babel-helpers/src/helpers/applyDecs2203.js b/packages/babel-helpers/src/helpers/applyDecs2203.js index 627b2e2747a5..2bd885c26419 100644 --- a/packages/babel-helpers/src/helpers/applyDecs2203.js +++ b/packages/babel-helpers/src/helpers/applyDecs2203.js @@ -39,7 +39,7 @@ function applyDecs2203Factory() { kind, isStatic, isPrivate, - value + value, ) { var kindStr; @@ -72,7 +72,7 @@ function applyDecs2203Factory() { if (kind !== 0 /* FIELD */) { ctx.addInitializer = createAddInitializerMethod( initializers, - decoratorFinishedRef + decoratorFinishedRef, ); } @@ -120,7 +120,7 @@ function applyDecs2203Factory() { function assertNotFinished(decoratorFinishedRef, fnName) { if (decoratorFinishedRef.v) { throw new Error( - "attempted to call " + fnName + " after decoration was finished" + "attempted to call " + fnName + " after decoration was finished", ); } } @@ -137,7 +137,7 @@ function applyDecs2203Factory() { if (kind === 1 /* ACCESSOR */) { if (type !== "object" || value === null) { throw new TypeError( - "accessor decorators must return an object with get, set, or init properties or void 0" + "accessor decorators must return an object with get, set, or init properties or void 0", ); } if (value.get !== undefined) { @@ -159,7 +159,7 @@ function applyDecs2203Factory() { hint = "method"; } throw new TypeError( - hint + " decorators must return a function or void 0" + hint + " decorators must return a function or void 0", ); } } @@ -172,7 +172,7 @@ function applyDecs2203Factory() { kind, isStatic, isPrivate, - initializers + initializers, ) { var decs = decInfo[0]; @@ -225,7 +225,7 @@ function applyDecs2203Factory() { kind, isStatic, isPrivate, - value + value, ); if (newValue !== void 0) { @@ -255,7 +255,7 @@ function applyDecs2203Factory() { kind, isStatic, isPrivate, - value + value, ); if (newValue !== void 0) { @@ -401,7 +401,7 @@ function applyDecs2203Factory() { ) { throw new Error( "Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + - name + name, ); } else if (!existingKind && kind > 2 /* METHOD */) { existingNonFields.set(name, kind); @@ -418,7 +418,7 @@ function applyDecs2203Factory() { kind, isStatic, isPrivate, - initializers + initializers, ); } @@ -452,7 +452,7 @@ function applyDecs2203Factory() { name: name, addInitializer: createAddInitializerMethod( initializers, - decoratorFinishedRef + decoratorFinishedRef, ), }); } finally { diff --git a/packages/babel-helpers/src/helpers/applyDecs2203R.js b/packages/babel-helpers/src/helpers/applyDecs2203R.js index 646b7826560c..0cd2b1429007 100644 --- a/packages/babel-helpers/src/helpers/applyDecs2203R.js +++ b/packages/babel-helpers/src/helpers/applyDecs2203R.js @@ -38,7 +38,7 @@ function applyDecs2203RFactory() { kind, isStatic, isPrivate, - value + value, ) { var kindStr; @@ -71,7 +71,7 @@ function applyDecs2203RFactory() { if (kind !== 0 /* FIELD */) { ctx.addInitializer = createAddInitializerMethod( initializers, - decoratorFinishedRef + decoratorFinishedRef, ); } @@ -119,7 +119,7 @@ function applyDecs2203RFactory() { function assertNotFinished(decoratorFinishedRef, fnName) { if (decoratorFinishedRef.v) { throw new Error( - "attempted to call " + fnName + " after decoration was finished" + "attempted to call " + fnName + " after decoration was finished", ); } } @@ -136,7 +136,7 @@ function applyDecs2203RFactory() { if (kind === 1 /* ACCESSOR */) { if (type !== "object" || value === null) { throw new TypeError( - "accessor decorators must return an object with get, set, or init properties or void 0" + "accessor decorators must return an object with get, set, or init properties or void 0", ); } if (value.get !== undefined) { @@ -158,7 +158,7 @@ function applyDecs2203RFactory() { hint = "method"; } throw new TypeError( - hint + " decorators must return a function or void 0" + hint + " decorators must return a function or void 0", ); } } @@ -171,7 +171,7 @@ function applyDecs2203RFactory() { kind, isStatic, isPrivate, - initializers + initializers, ) { var decs = decInfo[0]; @@ -233,7 +233,7 @@ function applyDecs2203RFactory() { kind, isStatic, isPrivate, - value + value, ); if (newValue !== void 0) { @@ -263,7 +263,7 @@ function applyDecs2203RFactory() { kind, isStatic, isPrivate, - value + value, ); if (newValue !== void 0) { @@ -410,7 +410,7 @@ function applyDecs2203RFactory() { ) { throw new Error( "Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + - name + name, ); } else if (!existingKind && kind > 2 /* METHOD */) { existingNonFields.set(name, kind); @@ -427,7 +427,7 @@ function applyDecs2203RFactory() { kind, isStatic, isPrivate, - initializers + initializers, ); } @@ -462,7 +462,7 @@ function applyDecs2203RFactory() { name: name, addInitializer: createAddInitializerMethod( initializers, - decoratorFinishedRef + decoratorFinishedRef, ), }); } finally { @@ -649,6 +649,6 @@ export default function applyDecs2203R(targetClass, memberDecs, classDecs) { return (applyDecs2203R = applyDecs2203RFactory())( targetClass, memberDecs, - classDecs + classDecs, ); } diff --git a/packages/babel-helpers/src/helpers/applyDecs2301.js b/packages/babel-helpers/src/helpers/applyDecs2301.js index d826a1537246..715ad7cb0bee 100644 --- a/packages/babel-helpers/src/helpers/applyDecs2301.js +++ b/packages/babel-helpers/src/helpers/applyDecs2301.js @@ -34,7 +34,7 @@ function applyDecs2301Factory() { function assertInstanceIfPrivate(has, target) { if (!has(target)) { throw new TypeError( - "Attempted to access private element on non-instance" + "Attempted to access private element on non-instance", ); } } @@ -48,7 +48,7 @@ function applyDecs2301Factory() { isStatic, isPrivate, value, - hasPrivateBrand + hasPrivateBrand, ) { var kindStr; @@ -81,7 +81,7 @@ function applyDecs2301Factory() { if (kind !== 0 /* FIELD */) { ctx.addInitializer = createAddInitializerMethod( initializers, - decoratorFinishedRef + decoratorFinishedRef, ); } @@ -151,7 +151,7 @@ function applyDecs2301Factory() { function assertNotFinished(decoratorFinishedRef, fnName) { if (decoratorFinishedRef.v) { throw new Error( - "attempted to call " + fnName + " after decoration was finished" + "attempted to call " + fnName + " after decoration was finished", ); } } @@ -168,7 +168,7 @@ function applyDecs2301Factory() { if (kind === 1 /* ACCESSOR */) { if (type !== "object" || value === null) { throw new TypeError( - "accessor decorators must return an object with get, set, or init properties or void 0" + "accessor decorators must return an object with get, set, or init properties or void 0", ); } if (value.get !== undefined) { @@ -190,7 +190,7 @@ function applyDecs2301Factory() { hint = "method"; } throw new TypeError( - hint + " decorators must return a function or void 0" + hint + " decorators must return a function or void 0", ); } } @@ -215,7 +215,7 @@ function applyDecs2301Factory() { isStatic, isPrivate, initializers, - hasPrivateBrand + hasPrivateBrand, ) { var decs = decInfo[0]; @@ -280,7 +280,7 @@ function applyDecs2301Factory() { isStatic, isPrivate, value, - hasPrivateBrand + hasPrivateBrand, ); if (newValue !== void 0) { @@ -311,7 +311,7 @@ function applyDecs2301Factory() { isStatic, isPrivate, value, - hasPrivateBrand + hasPrivateBrand, ); if (newValue !== void 0) { @@ -466,7 +466,7 @@ function applyDecs2301Factory() { ) { throw new Error( "Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + - name + name, ); } else if (!existingKind && kind > 2 /* METHOD */) { existingNonFields.set(name, kind); @@ -484,7 +484,7 @@ function applyDecs2301Factory() { isStatic, isPrivate, initializers, - hasPrivateBrand + hasPrivateBrand, ); } @@ -519,7 +519,7 @@ function applyDecs2301Factory() { name: name, addInitializer: createAddInitializerMethod( initializers, - decoratorFinishedRef + decoratorFinishedRef, ), }); } finally { @@ -694,7 +694,7 @@ function applyDecs2301Factory() { targetClass, memberDecs, classDecs, - instanceBrand + instanceBrand, ) { return { e: applyMemberDecs(targetClass, memberDecs, instanceBrand), @@ -710,12 +710,12 @@ export default function applyDecs2301( targetClass, memberDecs, classDecs, - instanceBrand + instanceBrand, ) { return (applyDecs2301 = applyDecs2301Factory())( targetClass, memberDecs, classDecs, - instanceBrand + instanceBrand, ); } diff --git a/packages/babel-helpers/src/helpers/callSuper.ts b/packages/babel-helpers/src/helpers/callSuper.ts new file mode 100644 index 000000000000..dc7fa83aa74c --- /dev/null +++ b/packages/babel-helpers/src/helpers/callSuper.ts @@ -0,0 +1,29 @@ +/* @minVersion 7.23.8 */ + +// This is duplicated to packages/babel-plugin-transform-classes/src/inline-callSuper-helpers.ts + +// @ts-expect-error helper +import getPrototypeOf from "getPrototypeOf"; +import isNativeReflectConstruct from "./isNativeReflectConstruct.ts"; +// @ts-expect-error helper +import possibleConstructorReturn from "possibleConstructorReturn"; + +export default function _callSuper( + _this: Function, + derived: Function, + args: any[], +) { + // Super + derived = getPrototypeOf(derived); + return possibleConstructorReturn( + _this, + isNativeReflectConstruct() + ? // NOTE: This doesn't work if this.__proto__.constructor has been modified. + Reflect.construct( + derived, + args || [], + getPrototypeOf(_this).constructor, + ) + : derived.apply(_this, args), + ); +} diff --git a/packages/babel-helpers/src/helpers/construct.ts b/packages/babel-helpers/src/helpers/construct.ts new file mode 100644 index 000000000000..07209274780c --- /dev/null +++ b/packages/babel-helpers/src/helpers/construct.ts @@ -0,0 +1,24 @@ +/* @minVersion 7.0.0-beta.0 */ + +// @ts-expect-error helper +import setPrototypeOf from "setPrototypeOf"; +import isNativeReflectConstruct from "./isNativeReflectConstruct.ts"; + +export default function _construct( + Parent: Function, + args: any[], + Class: Function, +): any { + if (isNativeReflectConstruct()) { + // Avoid issues with Class being present but undefined when it wasn't + // present in the original call. + return Reflect.construct.apply(null, arguments as any); + } + // NOTE: If Parent !== Class, the correct __proto__ is set *after* + // calling the constructor. + var a: any[] = [null]; + a.push.apply(a, args); + var instance = new (Parent.bind.apply(Parent, a))(); + if (Class) setPrototypeOf(instance, Class.prototype); + return instance; +} diff --git a/packages/babel-helpers/src/helpers/importDeferProxy.js b/packages/babel-helpers/src/helpers/importDeferProxy.js index 0d3249147e79..d4767fdd0085 100644 --- a/packages/babel-helpers/src/helpers/importDeferProxy.js +++ b/packages/babel-helpers/src/helpers/importDeferProxy.js @@ -26,6 +26,6 @@ export default function _importDeferProxy(init) { preventExtensions: constValue(true), set: constValue(false), setPrototypeOf: constValue(false), - } + }, ); } diff --git a/packages/babel-helpers/src/helpers/isNativeReflectConstruct.ts b/packages/babel-helpers/src/helpers/isNativeReflectConstruct.ts new file mode 100644 index 000000000000..58807bb3d858 --- /dev/null +++ b/packages/babel-helpers/src/helpers/isNativeReflectConstruct.ts @@ -0,0 +1,19 @@ +/* @minVersion 7.9.0 */ + +export default function _isNativeReflectConstruct() { + // Since Reflect.construct can't be properly polyfilled, some + // implementations (e.g. core-js@2) don't set the correct internal slots. + // Those polyfills don't allow us to subclass built-ins, so we need to + // use our fallback implementation. + try { + // If the internal slots aren't set, this throws an error similar to + // TypeError: this is not a Boolean object. + var result = !Boolean.prototype.valueOf.call( + Reflect.construct(Boolean, [], function () {}), + ); + } catch (e) {} + // @ts-expect-error assign to function + return (_isNativeReflectConstruct = function () { + return !!result; + })(); +} diff --git a/packages/babel-helpers/src/helpers/objectSpread2.js b/packages/babel-helpers/src/helpers/objectSpread2.js index 685706404ccb..3bf9edc2487a 100644 --- a/packages/babel-helpers/src/helpers/objectSpread2.js +++ b/packages/babel-helpers/src/helpers/objectSpread2.js @@ -34,7 +34,7 @@ export default function _objectSpread2(target) { Object.defineProperty( target, key, - Object.getOwnPropertyDescriptor(source, key) + Object.getOwnPropertyDescriptor(source, key), ); }); } diff --git a/packages/babel-helpers/src/helpers/using.js b/packages/babel-helpers/src/helpers/using.js index ce9bdb1ef4b0..0e6f6a7e3a74 100644 --- a/packages/babel-helpers/src/helpers/using.js +++ b/packages/babel-helpers/src/helpers/using.js @@ -4,7 +4,7 @@ export default function _using(stack, value, isAwait) { if (value === null || value === void 0) return value; if (Object(value) !== value) { throw new TypeError( - "using declarations can only be used with objects, functions, null, or undefined." + "using declarations can only be used with objects, functions, null, or undefined.", ); } // core-js-pure uses Symbol.for for polyfilling well-known symbols diff --git a/packages/babel-helpers/src/helpers/wrapRegExp.js b/packages/babel-helpers/src/helpers/wrapRegExp.js index 29a81aa7800b..cc913d310e64 100644 --- a/packages/babel-helpers/src/helpers/wrapRegExp.js +++ b/packages/babel-helpers/src/helpers/wrapRegExp.js @@ -37,7 +37,7 @@ export default function _wrapRegExp() { substitution.replace(/\$<([^>]+)>/g, function (_, name) { var group = groups[name]; return "$" + (Array.isArray(group) ? group.join("$") : group); - }) + }), ); } else if (typeof substitution === "function") { var _this = this; diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/7030/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/7030/output.js index fc2cae5a5a0f..77b7dadbd3d7 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/7030/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/7030/output.js @@ -13,11 +13,10 @@ var A = /*#__PURE__*/function (_B) { "use strict"; babelHelpers.inherits(A, _B); - var _super = babelHelpers.createSuper(A); function A(timestamp) { var _this; babelHelpers.classCallCheck(this, A); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, A); _this.timestamp = timestamp; _this.moment = moment(timestamp); return _this; diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/assumption-setPublicClassFields/foobar/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/assumption-setPublicClassFields/foobar/output.js index 397ae0c4e3af..d6439bd3040b 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/assumption-setPublicClassFields/foobar/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/assumption-setPublicClassFields/foobar/output.js @@ -2,11 +2,10 @@ var Child = /*#__PURE__*/function (_Parent) { "use strict"; babelHelpers.inherits(Child, _Parent); - var _super = babelHelpers.createSuper(Child); function Child() { var _this; babelHelpers.classCallCheck(this, Child); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Child); _this.scopedFunctionWithThis = function () { _this.name = {}; }; diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-call-in-decorator/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-call-in-decorator/output.js index 900171551838..2183b4929db9 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-call-in-decorator/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-call-in-decorator/output.js @@ -6,12 +6,11 @@ let Hello = /*#__PURE__*/babelHelpers.createClass(function Hello() { }); let Outer = /*#__PURE__*/function (_Hello) { babelHelpers.inherits(Outer, _Hello); - var _super = babelHelpers.createSuper(Outer); function Outer() { var _dec, _init_hello, _class; var _this; babelHelpers.classCallCheck(this, Outer); - _dec = _this = _super.call(this); + _dec = _this = babelHelpers.callSuper(this, Outer); let Inner = /*#__PURE__*/babelHelpers.createClass(function Inner() { babelHelpers.classCallCheck(this, Inner); babelHelpers.defineProperty(this, "hello", _init_hello(this)); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-call-in-key/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-call-in-key/output.js index 9aea53d395af..c681881fd420 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-call-in-key/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-call-in-key/output.js @@ -10,11 +10,10 @@ let Hello = /*#__PURE__*/babelHelpers.createClass(function Hello() { }); let Outer = /*#__PURE__*/function (_Hello) { babelHelpers.inherits(Outer, _Hello); - var _super = babelHelpers.createSuper(Outer); function Outer() { var _this; babelHelpers.classCallCheck(this, Outer); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Outer); let Inner = /*#__PURE__*/babelHelpers.createClass(function Inner() { babelHelpers.classCallCheck(this, Inner); babelHelpers.defineProperty(this, _this, "hello"); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-property-in-accessor-key/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-property-in-accessor-key/output.js index f0b62be55928..78cb8c0fc97b 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-property-in-accessor-key/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-property-in-accessor-key/output.js @@ -14,12 +14,11 @@ let Hello = /*#__PURE__*/function () { }(); let Outer = /*#__PURE__*/function (_Hello) { babelHelpers.inherits(Outer, _Hello); - var _super = babelHelpers.createSuper(Outer); function Outer() { var _computedKey; var _thisSuper, _this; babelHelpers.classCallCheck(this, Outer); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Outer); _computedKey = babelHelpers.toPropertyKey(babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Outer.prototype)), "toString", _thisSuper).call(_thisSuper)); var _A = /*#__PURE__*/new WeakMap(); let Inner = /*#__PURE__*/function () { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-property-in-decorator/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-property-in-decorator/output.js index 4b063426b099..3ee7c3b3eef5 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-property-in-decorator/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-property-in-decorator/output.js @@ -14,12 +14,11 @@ let Hello = /*#__PURE__*/function () { }(); let Outer = /*#__PURE__*/function (_Hello) { babelHelpers.inherits(Outer, _Hello); - var _super = babelHelpers.createSuper(Outer); function Outer() { var _dec, _init_hello, _class; var _thisSuper, _this; babelHelpers.classCallCheck(this, Outer); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Outer); _dec = babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Outer.prototype)), "dec", _thisSuper); let Inner = /*#__PURE__*/babelHelpers.createClass(function Inner() { babelHelpers.classCallCheck(this, Inner); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-property-in-key/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-property-in-key/output.js index 7c135e094c4b..2cdbeee35d4c 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-property-in-key/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/nested-class/super-property-in-key/output.js @@ -14,12 +14,11 @@ let Hello = /*#__PURE__*/function () { }(); let Outer = /*#__PURE__*/function (_Hello) { babelHelpers.inherits(Outer, _Hello); - var _super = babelHelpers.createSuper(Outer); function Outer() { let _babelHelpers$get$cal; var _thisSuper, _this; babelHelpers.classCallCheck(this, Outer); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Outer); _babelHelpers$get$cal = babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Outer.prototype)), "toString", _thisSuper).call(_thisSuper); let Inner = /*#__PURE__*/babelHelpers.createClass(function Inner() { babelHelpers.classCallCheck(this, Inner); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/derived-multiple-supers/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/derived-multiple-supers/output.js index f8204d85bbe5..0f07b891c1eb 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/derived-multiple-supers/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/derived-multiple-supers/output.js @@ -3,18 +3,17 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); if (condition) { - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Foo); Object.defineProperty(babelHelpers.assertThisInitialized(_this), _bar, { writable: true, value: "foo" }); } else { - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Foo); Object.defineProperty(babelHelpers.assertThisInitialized(_this), _bar, { writable: true, value: "foo" diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/derived/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/derived/output.js index ed347215ef56..67a73d612de0 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/derived/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/derived/output.js @@ -13,11 +13,10 @@ var Bar = /*#__PURE__*/function (_Foo) { "use strict"; babelHelpers.inherits(Bar, _Foo); - var _super = babelHelpers.createSuper(Bar); function Bar(...args) { var _this; babelHelpers.classCallCheck(this, Bar); - _this = _super.call(this, ...args); + _this = babelHelpers.callSuper(this, Bar, [...args]); Object.defineProperty(babelHelpers.assertThisInitialized(_this), _prop2, { writable: true, value: "bar" diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/foobar/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/foobar/output.js index a581d5e33ed4..7c3c26ce9264 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/foobar/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/foobar/output.js @@ -3,11 +3,10 @@ let Child = /*#__PURE__*/function (_Parent) { "use strict"; babelHelpers.inherits(Child, _Parent); - var _super = babelHelpers.createSuper(Child); function Child() { var _this; babelHelpers.classCallCheck(this, Child); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Child); Object.defineProperty(babelHelpers.assertThisInitialized(_this), _scopedFunctionWithThis, { writable: true, value: function () { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/nested-class-extends-computed-redeclared/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/nested-class-extends-computed-redeclared/output.js index e30161605f53..44aad9fd396b 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/nested-class-extends-computed-redeclared/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/nested-class-extends-computed-redeclared/output.js @@ -17,11 +17,10 @@ var Foo = /*#__PURE__*/function () { var _foo2 = /*#__PURE__*/babelHelpers.classPrivateFieldLooseKey("foo"); var Nested = /*#__PURE__*/function (_ref) { babelHelpers.inherits(Nested, _ref); - var _super = babelHelpers.createSuper(Nested); function Nested(...args) { var _this; babelHelpers.classCallCheck(this, Nested); - _this = _super.call(this, ...args); + _this = babelHelpers.callSuper(this, Nested, [...args]); Object.defineProperty(babelHelpers.assertThisInitialized(_this), _foo2, { writable: true, value: 3 diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/nested-class-extends-computed/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/nested-class-extends-computed/output.js index 75ffa754bece..590faa44914f 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/nested-class-extends-computed/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/nested-class-extends-computed/output.js @@ -16,11 +16,10 @@ var Foo = /*#__PURE__*/function () { var _foo2 = /*#__PURE__*/babelHelpers.classPrivateFieldLooseKey("foo"); var Nested = /*#__PURE__*/function (_ref) { babelHelpers.inherits(Nested, _ref); - var _super = babelHelpers.createSuper(Nested); function Nested(...args) { var _this; babelHelpers.classCallCheck(this, Nested); - _this = _super.call(this, ...args); + _this = babelHelpers.callSuper(this, Nested, [...args]); Object.defineProperty(babelHelpers.assertThisInitialized(_this), _foo2, { writable: true, value: 3 diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/private-in-derived/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/private-in-derived/output.js index 40157963b86b..0b8439a3be18 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/private-in-derived/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/private-in-derived/output.js @@ -9,10 +9,9 @@ var Outer = /*#__PURE__*/babelHelpers.createClass(function Outer() { }); var Test = /*#__PURE__*/function (_babelHelpers$classPr) { babelHelpers.inherits(Test, _babelHelpers$classPr); - var _super = babelHelpers.createSuper(Test); function Test() { babelHelpers.classCallCheck(this, Test); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Test, arguments); } return babelHelpers.createClass(Test); }(babelHelpers.classPrivateFieldLooseBase(this, _outer)[_outer]); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/super-expression/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/super-expression/output.js index d133f7f131f2..0a13eeaecd56 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/super-expression/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/super-expression/output.js @@ -3,11 +3,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); - foo((_this = _super.call(this), Object.defineProperty(babelHelpers.assertThisInitialized(_this), _bar, { + foo((_this = babelHelpers.callSuper(this, Foo), Object.defineProperty(babelHelpers.assertThisInitialized(_this), _bar, { writable: true, value: "foo" }), babelHelpers.assertThisInitialized(_this))); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/super-statement/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/super-statement/output.js index 8b4d96cf3750..dcea898bee57 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/super-statement/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/super-statement/output.js @@ -3,11 +3,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Foo); Object.defineProperty(babelHelpers.assertThisInitialized(_this), _bar, { writable: true, value: "foo" diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/derived-multiple-supers/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/derived-multiple-supers/output.js index 81fee477a597..e04525edba73 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/derived-multiple-supers/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/derived-multiple-supers/output.js @@ -3,18 +3,17 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); if (condition) { - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Foo); babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _bar, { writable: true, value: "foo" }); } else { - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Foo); babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _bar, { writable: true, value: "foo" diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/derived/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/derived/output.js index a3e4200bb4c0..4410b9c9aa26 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/derived/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/derived/output.js @@ -13,11 +13,10 @@ var Bar = /*#__PURE__*/function (_Foo) { "use strict"; babelHelpers.inherits(Bar, _Foo); - var _super = babelHelpers.createSuper(Bar); function Bar(...args) { var _this; babelHelpers.classCallCheck(this, Bar); - _this = _super.call(this, ...args); + _this = babelHelpers.callSuper(this, Bar, [...args]); babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _prop2, { writable: true, value: "bar" diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/foobar/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/foobar/output.js index 0120e634038d..ac62ad7e7ad3 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/foobar/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/foobar/output.js @@ -3,11 +3,10 @@ var Child = /*#__PURE__*/function (_Parent) { "use strict"; babelHelpers.inherits(Child, _Parent); - var _super = babelHelpers.createSuper(Child); function Child() { var _this; babelHelpers.classCallCheck(this, Child); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Child); babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _scopedFunctionWithThis, { writable: true, value: () => { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/nested-class-extends-computed-redeclared/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/nested-class-extends-computed-redeclared/output.js index 020f5e71a2d3..cfee0900e5d3 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/nested-class-extends-computed-redeclared/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/nested-class-extends-computed-redeclared/output.js @@ -17,11 +17,10 @@ var Foo = /*#__PURE__*/function () { var _foo2 = /*#__PURE__*/new WeakMap(); var Nested = /*#__PURE__*/function (_ref) { babelHelpers.inherits(Nested, _ref); - var _super = babelHelpers.createSuper(Nested); function Nested(...args) { var _this; babelHelpers.classCallCheck(this, Nested); - _this = _super.call(this, ...args); + _this = babelHelpers.callSuper(this, Nested, [...args]); babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _foo2, { writable: true, value: 3 diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/nested-class-extends-computed/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/nested-class-extends-computed/output.js index 9b95beb04582..9e8c8b37a2d7 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/nested-class-extends-computed/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/nested-class-extends-computed/output.js @@ -16,11 +16,10 @@ var Foo = /*#__PURE__*/function () { var _foo2 = /*#__PURE__*/new WeakMap(); var Nested = /*#__PURE__*/function (_ref) { babelHelpers.inherits(Nested, _ref); - var _super = babelHelpers.createSuper(Nested); function Nested(...args) { var _this; babelHelpers.classCallCheck(this, Nested); - _this = _super.call(this, ...args); + _this = babelHelpers.callSuper(this, Nested, [...args]); babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _foo2, { writable: true, value: 3 diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/private-in-derived/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/private-in-derived/output.js index 3765b3ecdd41..0599050446d9 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/private-in-derived/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/private-in-derived/output.js @@ -9,10 +9,9 @@ var Outer = /*#__PURE__*/babelHelpers.createClass(function Outer() { }); var Test = /*#__PURE__*/function (_babelHelpers$classPr) { babelHelpers.inherits(Test, _babelHelpers$classPr); - var _super = babelHelpers.createSuper(Test); function Test() { babelHelpers.classCallCheck(this, Test); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Test, arguments); } return babelHelpers.createClass(Test); }(babelHelpers.classPrivateFieldGet(this, _outer)); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/super-call/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/super-call/output.js index f2c7d6ab17ba..5a0eaf3e1d86 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/super-call/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/super-call/output.js @@ -17,11 +17,10 @@ var B = /*#__PURE__*/function (_A) { "use strict"; babelHelpers.inherits(B, _A); - var _super = babelHelpers.createSuper(B); function B(...args) { var _thisSuper, _this; babelHelpers.classCallCheck(this, B); - _this = _super.call(this, ...args); + _this = babelHelpers.callSuper(this, B, [...args]); babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _foo, { writable: true, value: babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(B.prototype)), "foo", _thisSuper).call(_thisSuper) diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/super-expression/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/super-expression/output.js index e3df7140292f..13530909b7d6 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/super-expression/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/super-expression/output.js @@ -3,11 +3,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); - foo((_this = _super.call(this), babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _bar, { + foo((_this = babelHelpers.callSuper(this, Foo), babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _bar, { writable: true, value: "foo" }), babelHelpers.assertThisInitialized(_this))); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/super-statement/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/super-statement/output.js index d260e30f94a8..7ed3ad4e99fa 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/super-statement/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/super-statement/output.js @@ -3,11 +3,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Foo); babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _bar, { writable: true, value: "foo" diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/derived/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/derived/output.js index d0cdbfbc13c7..fe91b2a66031 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/derived/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/derived/output.js @@ -2,11 +2,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo(...args) { var _this; babelHelpers.classCallCheck(this, Foo); - _this = _super.call(this, ...args); + _this = babelHelpers.callSuper(this, Foo, [...args]); _this.bar = "foo"; return _this; } diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/foobar/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/foobar/output.js index be255c37ca80..c3a937ddef6e 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/foobar/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/foobar/output.js @@ -2,11 +2,10 @@ let Child = /*#__PURE__*/function (_Parent) { "use strict"; babelHelpers.inherits(Child, _Parent); - var _super = babelHelpers.createSuper(Child); function Child() { var _this; babelHelpers.classCallCheck(this, Child); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Child); _this.scopedFunctionWithThis = function () { _this.name = {}; }; diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/regression-T6719/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/regression-T6719/output.js index d4946cde4a5a..d6e31273e870 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/regression-T6719/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/regression-T6719/output.js @@ -4,10 +4,9 @@ function withContext(ComposedComponent) { "use strict"; babelHelpers.inherits(WithContext, _Component); - var _super = babelHelpers.createSuper(WithContext); function WithContext() { babelHelpers.classCallCheck(this, WithContext); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, WithContext, arguments); } return babelHelpers.createClass(WithContext); }(Component), _class.propTypes = { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/static-super/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/static-super/output.js index d5d169dcc3a5..383f5956dd73 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/static-super/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/static-super/output.js @@ -8,10 +8,9 @@ var B = /*#__PURE__*/function (_A) { "use strict"; babelHelpers.inherits(B, _A); - var _super = babelHelpers.createSuper(B); function B() { babelHelpers.classCallCheck(this, B); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, B, arguments); } return babelHelpers.createClass(B); }(A); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/super-call/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/super-call/output.js index 34baabc803ea..df724ef004de 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/super-call/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/super-call/output.js @@ -16,11 +16,10 @@ var B = /*#__PURE__*/function (_A) { "use strict"; babelHelpers.inherits(B, _A); - var _super = babelHelpers.createSuper(B); function B(...args) { var _thisSuper, _this; babelHelpers.classCallCheck(this, B); - _this = _super.call(this, ...args); + _this = babelHelpers.callSuper(this, B, [...args]); _this.foo = babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(B.prototype)), "foo", _thisSuper).call(_thisSuper); return _this; } diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/super-expression/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/super-expression/output.js index 2ef37c1a7dc3..d5ec7f5c665c 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/super-expression/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/super-expression/output.js @@ -2,11 +2,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); - foo((_this = _super.call(this), _this.bar = "foo", babelHelpers.assertThisInitialized(_this))); + foo((_this = babelHelpers.callSuper(this, Foo), _this.bar = "foo", babelHelpers.assertThisInitialized(_this))); return _this; } return babelHelpers.createClass(Foo); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/super-statement/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/super-statement/output.js index f7bfcdcbb05e..f2af43f03918 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/super-statement/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/super-statement/output.js @@ -2,11 +2,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Foo); _this.bar = "foo"; return _this; } diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public/derived-multiple-supers/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/public/derived-multiple-supers/output.js index ee7e43486b87..f35ef99c9f00 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public/derived-multiple-supers/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public/derived-multiple-supers/output.js @@ -2,15 +2,14 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); if (condition) { - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Foo); babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "bar", "foo"); } else { - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Foo); babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "bar", "foo"); } return babelHelpers.possibleConstructorReturn(_this); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public/derived/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/public/derived/output.js index 54e3e1f660ae..4359dd083ef4 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public/derived/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public/derived/output.js @@ -2,11 +2,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo(...args) { var _this; babelHelpers.classCallCheck(this, Foo); - _this = _super.call(this, ...args); + _this = babelHelpers.callSuper(this, Foo, [...args]); babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "bar", "foo"); return _this; } diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public/foobar/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/public/foobar/output.js index 81ac22119f23..dccf09d66d54 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public/foobar/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public/foobar/output.js @@ -2,11 +2,10 @@ var Child = /*#__PURE__*/function (_Parent) { "use strict"; babelHelpers.inherits(Child, _Parent); - var _super = babelHelpers.createSuper(Child); function Child() { var _this; babelHelpers.classCallCheck(this, Child); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Child); babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "scopedFunctionWithThis", function () { _this.name = {}; }); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public/regression-T6719/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/public/regression-T6719/output.js index 4e648b0ca70a..0776a29cfb59 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public/regression-T6719/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public/regression-T6719/output.js @@ -4,10 +4,9 @@ function withContext(ComposedComponent) { "use strict"; babelHelpers.inherits(WithContext, _Component); - var _super = babelHelpers.createSuper(WithContext); function WithContext() { babelHelpers.classCallCheck(this, WithContext); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, WithContext, arguments); } return babelHelpers.createClass(WithContext); }(Component), babelHelpers.defineProperty(_class, "propTypes", { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public/static-super/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/public/static-super/output.js index 000cbc8067c6..90819fc1b22b 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public/static-super/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public/static-super/output.js @@ -9,10 +9,9 @@ var B = /*#__PURE__*/function (_A) { "use strict"; babelHelpers.inherits(B, _A); - var _super = babelHelpers.createSuper(B); function B() { babelHelpers.classCallCheck(this, B); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, B, arguments); } return babelHelpers.createClass(B); }(A); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public/super-call/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/public/super-call/output.js index 583c9e29e26a..54f4e1979c3a 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public/super-call/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public/super-call/output.js @@ -16,11 +16,10 @@ var B = /*#__PURE__*/function (_A) { "use strict"; babelHelpers.inherits(B, _A); - var _super = babelHelpers.createSuper(B); function B(...args) { var _thisSuper, _this; babelHelpers.classCallCheck(this, B); - _this = _super.call(this, ...args); + _this = babelHelpers.callSuper(this, B, [...args]); babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "foo", babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(B.prototype)), "foo", _thisSuper).call(_thisSuper)); return _this; } diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public/super-expression/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/public/super-expression/output.js index a7cd74cce495..36ec90612544 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public/super-expression/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public/super-expression/output.js @@ -2,11 +2,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); - foo((_this = _super.call(this), babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "bar", "foo"))); + foo((_this = babelHelpers.callSuper(this, Foo), babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "bar", "foo"))); return _this; } return babelHelpers.createClass(Foo); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public/super-statement/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/public/super-statement/output.js index d8b76cce8a26..266f70dc1128 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public/super-statement/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public/super-statement/output.js @@ -2,11 +2,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Foo); babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "bar", "foo"); return _this; } diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/regression/6154/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/regression/6154/output.js index e281129206e7..a93e976e8e3a 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/regression/6154/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/regression/6154/output.js @@ -5,14 +5,13 @@ var Test = /*#__PURE__*/babelHelpers.createClass(function Test() { babelHelpers.classCallCheck(this, Test); var Other = /*#__PURE__*/function (_Test) { babelHelpers.inherits(Other, _Test); - var _super = babelHelpers.createSuper(Other); function Other() { var _thisSuper, _this; babelHelpers.classCallCheck(this, Other); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } - _this = _super.call.apply(_super, [this].concat(args)); + _this = babelHelpers.callSuper(this, Other, [].concat(args)); babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "a", function () { return babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Other.prototype)), "test", _thisSuper); }); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/regression/T6719/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/regression/T6719/output.js index d4946cde4a5a..d6e31273e870 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/regression/T6719/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/regression/T6719/output.js @@ -4,10 +4,9 @@ function withContext(ComposedComponent) { "use strict"; babelHelpers.inherits(WithContext, _Component); - var _super = babelHelpers.createSuper(WithContext); function WithContext() { babelHelpers.classCallCheck(this, WithContext); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, WithContext, arguments); } return babelHelpers.createClass(WithContext); }(Component), _class.propTypes = { diff --git a/packages/babel-plugin-transform-classes/package.json b/packages/babel-plugin-transform-classes/package.json index 2e42223de711..3a03646ebe22 100644 --- a/packages/babel-plugin-transform-classes/package.json +++ b/packages/babel-plugin-transform-classes/package.json @@ -18,7 +18,6 @@ "@babel/helper-compilation-targets": "workspace:^", "@babel/helper-environment-visitor": "workspace:^", "@babel/helper-function-name": "workspace:^", - "@babel/helper-optimise-call-expression": "workspace:^", "@babel/helper-plugin-utils": "workspace:^", "@babel/helper-replace-supers": "workspace:^", "@babel/helper-split-export-declaration": "workspace:^", diff --git a/packages/babel-plugin-transform-classes/src/inline-createSuper-helpers.ts b/packages/babel-plugin-transform-classes/src/inline-callSuper-helpers.ts similarity index 63% rename from packages/babel-plugin-transform-classes/src/inline-createSuper-helpers.ts rename to packages/babel-plugin-transform-classes/src/inline-callSuper-helpers.ts index 8f7fdfb0dce0..07cdabac6e34 100644 --- a/packages/babel-plugin-transform-classes/src/inline-createSuper-helpers.ts +++ b/packages/babel-plugin-transform-classes/src/inline-callSuper-helpers.ts @@ -1,7 +1,11 @@ import { template, types as t, type File } from "@babel/core"; const helper = template.statement` - function CREATE_SUPER(Derived) { + function CALL_SUPER( + _this, + derived, + args, + ) { function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; @@ -19,31 +23,32 @@ const helper = template.statement` // use our fallback implementation. try { // If the internal slots aren't set, this throws an error similar to - // TypeError: this is not a Date object. - Date.prototype.toString.call(Reflect.construct(Date, [], function() {})); - return true; + // TypeError: this is not a Boolean object. + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}),); } catch (e) { return false; } } - return function () { - var Super = GET_PROTOTYPE_OF(Derived), result; - if (isNativeReflectConstruct()) { - // NOTE: This doesn't work if this.__proto__.constructor has been modified. - var NewTarget = GET_PROTOTYPE_OF(this).constructor; - result = Reflect.construct(Super, arguments, NewTarget); - } else { - result = Super.apply(this, arguments); - } - return POSSIBLE_CONSTRUCTOR_RETURN(this, result); - } + // Super + derived = GET_PROTOTYPE_OF(derived); + return POSSIBLE_CONSTRUCTOR_RETURN( + _this, + isNativeReflectConstruct() + ? // NOTE: This doesn't work if this.__proto__.constructor has been modified. + Reflect.construct( + derived, + args || [], + GET_PROTOTYPE_OF(_this).constructor, + ) + : derived.apply(_this, args), + ); } `; const helperIDs = new WeakMap(); -export default function addCreateSuperHelper(file: File) { +export default function addCallSuperHelper(file: File) { if (helperIDs.has(file)) { // TODO: Only use t.cloneNode in Babel 8 // t.cloneNode isn't supported in every version @@ -51,16 +56,16 @@ export default function addCreateSuperHelper(file: File) { } try { - return file.addHelper("createSuper"); + return file.addHelper("callSuper"); } catch { - // Babel <7.9.0 doesn't support the helper. + // old Babel doesn't support the helper. } - const id = file.scope.generateUidIdentifier("createSuper"); + const id = file.scope.generateUidIdentifier("callSuper"); helperIDs.set(file, id); const fn = helper({ - CREATE_SUPER: id, + CALL_SUPER: id, GET_PROTOTYPE_OF: file.addHelper("getPrototypeOf"), POSSIBLE_CONSTRUCTOR_RETURN: file.addHelper("possibleConstructorReturn"), }); diff --git a/packages/babel-plugin-transform-classes/src/transformClass.ts b/packages/babel-plugin-transform-classes/src/transformClass.ts index 8167cd8cbcf0..211fe0265b89 100644 --- a/packages/babel-plugin-transform-classes/src/transformClass.ts +++ b/packages/babel-plugin-transform-classes/src/transformClass.ts @@ -2,11 +2,10 @@ import type { NodePath, Scope, Visitor } from "@babel/traverse"; import nameFunction from "@babel/helper-function-name"; import ReplaceSupers from "@babel/helper-replace-supers"; import environmentVisitor from "@babel/helper-environment-visitor"; -import optimiseCall from "@babel/helper-optimise-call-expression"; import { traverse, template, types as t, type File } from "@babel/core"; import annotateAsPure from "@babel/helper-annotate-as-pure"; -import addCreateSuperHelper from "./inline-createSuper-helpers.ts"; +import addCallSuperHelper from "./inline-callSuper-helpers.ts"; type ClassAssumptions = { setClassMethods: boolean; @@ -48,7 +47,6 @@ type State = { classId: t.Identifier | void; classRef: t.Identifier; - superFnId: t.Identifier; superName: t.Expression | null; superReturns: NodePath[]; isDerived: boolean; @@ -109,7 +107,6 @@ export default function transformClass( classId: undefined, classRef: undefined, - superFnId: undefined, superName: null, superReturns: [], isDerived: false, @@ -342,12 +339,41 @@ export default function transformClass( call = t.logicalExpression("||", bareSuperNode, t.thisExpression()); } else { - call = optimiseCall( - t.cloneNode(classState.superFnId), + const args: t.Expression[] = [ t.thisExpression(), - bareSuperNode.arguments, - false, - ); + t.cloneNode(classState.classRef), + ]; + if (bareSuperNode.arguments?.length) { + const bareSuperNodeArguments = bareSuperNode.arguments as ( + | t.Expression + | t.SpreadElement + )[]; + + /** + * test262/test/language/expressions/super/call-spread-err-sngl-err-itr-get-get.js + * + * var iter = {}; + * Object.defineProperty(iter, Symbol.iterator, { + * get: function() { + * throw new Test262Error(); + * } + * }) + * super(...iter); + */ + + if ( + bareSuperNodeArguments.length === 1 && + t.isSpreadElement(bareSuperNodeArguments[0]) && + t.isIdentifier(bareSuperNodeArguments[0].argument, { + name: "arguments", + }) + ) { + args.push(bareSuperNodeArguments[0].argument); + } else { + args.push(t.arrayExpression(bareSuperNodeArguments)); + } + } + call = t.callExpression(addCallSuperHelper(classState.file), args); } if ( @@ -661,26 +687,11 @@ export default function transformClass( function pushInheritsToBody() { if (!classState.isDerived || classState.pushedInherits) return; - const superFnId = path.scope.generateUidIdentifier("super"); - - setState({ pushedInherits: true, superFnId }); + classState.pushedInherits = true; // Unshift to ensure that the constructor inheritance is set up before // any properties can be assigned to the prototype. - if (!assumptions.superIsCallableConstructor) { - classState.body.unshift( - t.variableDeclaration("var", [ - t.variableDeclarator( - superFnId, - t.callExpression(addCreateSuperHelper(classState.file), [ - t.cloneNode(classState.classRef), - ]), - ), - ]), - ); - } - classState.body.unshift( t.expressionStatement( t.callExpression( diff --git a/packages/babel-plugin-transform-classes/test/fixtures/assumption-constantSuper/accessing-super-class/output.js b/packages/babel-plugin-transform-classes/test/fixtures/assumption-constantSuper/accessing-super-class/output.js index 75cc50d3ad48..cc97b779fbaa 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/assumption-constantSuper/accessing-super-class/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/assumption-constantSuper/accessing-super-class/output.js @@ -2,16 +2,15 @@ var Test = /*#__PURE__*/function (_Foo) { "use strict"; babelHelpers.inherits(Test, _Foo); - var _super = babelHelpers.createSuper(Test); function Test() { var _Foo$prototype$test; var _this; babelHelpers.classCallCheck(this, Test); woops.super.test(); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Test); _Foo.prototype.test.call(babelHelpers.assertThisInitialized(_this)); - _this = _super.apply(this, arguments); - _this = _super.call.apply(_super, [this, "test"].concat(Array.prototype.slice.call(arguments))); + _this = babelHelpers.callSuper(this, Test, arguments); + _this = babelHelpers.callSuper(this, Test, ["test"].concat(Array.prototype.slice.call(arguments))); _Foo.prototype.test.apply(babelHelpers.assertThisInitialized(_this), arguments); (_Foo$prototype$test = _Foo.prototype.test).call.apply(_Foo$prototype$test, [babelHelpers.assertThisInitialized(_this), "test"].concat(Array.prototype.slice.call(arguments))); return _this; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/assumption-constantSuper/accessing-super-properties/output.js b/packages/babel-plugin-transform-classes/test/fixtures/assumption-constantSuper/accessing-super-properties/output.js index b5b6ca0da636..a59458852fa4 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/assumption-constantSuper/accessing-super-properties/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/assumption-constantSuper/accessing-super-properties/output.js @@ -2,11 +2,10 @@ var Test = /*#__PURE__*/function (_Foo) { "use strict"; babelHelpers.inherits(Test, _Foo); - var _super = babelHelpers.createSuper(Test); function Test() { var _this; babelHelpers.classCallCheck(this, Test); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Test); _Foo.prototype.test; _Foo.prototype.test.whatever; return _this; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/assumption-constantSuper/calling-super-properties/output.js b/packages/babel-plugin-transform-classes/test/fixtures/assumption-constantSuper/calling-super-properties/output.js index dd0343d30e58..e128c8ea5c9d 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/assumption-constantSuper/calling-super-properties/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/assumption-constantSuper/calling-super-properties/output.js @@ -2,11 +2,10 @@ var Test = /*#__PURE__*/function (_Foo) { "use strict"; babelHelpers.inherits(Test, _Foo); - var _super = babelHelpers.createSuper(Test); function Test() { var _this; babelHelpers.classCallCheck(this, Test); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Test); _Foo.prototype.test.whatever(); _Foo.prototype.test.call(babelHelpers.assertThisInitialized(_this)); return _this; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/assumption-noCallClass/with-superClass/output.js b/packages/babel-plugin-transform-classes/test/fixtures/assumption-noCallClass/with-superClass/output.js index 1205a9d19abb..e174b9a9c8f1 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/assumption-noCallClass/with-superClass/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/assumption-noCallClass/with-superClass/output.js @@ -5,10 +5,9 @@ var A = /*#__PURE__*/function (_B) { "use strict"; babelHelpers.inherits(A, _B); - var _super = babelHelpers.createSuper(A); function A(track) { var _this; - if (track !== undefined) _this = _super.call(this, track);else _this = _super.call(this); + if (track !== undefined) _this = babelHelpers.callSuper(this, A, [track]);else _this = babelHelpers.callSuper(this, A); return babelHelpers.possibleConstructorReturn(_this); } return babelHelpers.createClass(A); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/shadowed/output.js b/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/shadowed/output.js index 9a73d666d85a..cc9183b81e56 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/shadowed/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/shadowed/output.js @@ -7,10 +7,9 @@ let List = /*#__PURE__*/function (_Array) { "use strict"; babelHelpers.inherits(List, _Array); - var _super = babelHelpers.createSuper(List); function List() { babelHelpers.classCallCheck(this, List); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, List, arguments); } return babelHelpers.createClass(List); }(Array); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/spec/output.js b/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/spec/output.js index be98b74c06e4..87da9727a180 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/spec/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/extend-builtins/spec/output.js @@ -2,10 +2,9 @@ var List = /*#__PURE__*/function (_Array) { "use strict"; babelHelpers.inherits(List, _Array); - var _super = babelHelpers.createSuper(List); function List() { babelHelpers.classCallCheck(this, List); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, List, arguments); } return babelHelpers.createClass(List); }( /*#__PURE__*/babelHelpers.wrapNativeSuper(Array)); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-data-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-data-defined-on-parent/output.js index 116a14abcaf9..34faaf65d903 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-data-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-data-defined-on-parent/output.js @@ -16,10 +16,9 @@ let Base = /*#__PURE__*/function () { }(); let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "call", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-getter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-getter-defined-on-parent/output.js index 1065df33be55..be20d33a27ea 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-getter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-getter-defined-on-parent/output.js @@ -19,10 +19,9 @@ let Base = /*#__PURE__*/function () { }(); let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "call", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-not-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-not-defined-on-parent/output.js index f1a392b61dc8..1f6f6d43450f 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-not-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-not-defined-on-parent/output.js @@ -5,10 +5,9 @@ let Base = /*#__PURE__*/babelHelpers.createClass(function Base() { }); let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "call", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-setter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-setter-defined-on-parent/output.js index 0edb8a713cb7..ee4c492ab12a 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-setter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/call-semantics-setter-defined-on-parent/output.js @@ -14,10 +14,9 @@ let Base = /*#__PURE__*/function () { }(); let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "call", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-data-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-data-defined-on-parent/output.js index bf813042692d..34f14674a0ba 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-data-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-data-defined-on-parent/output.js @@ -6,10 +6,9 @@ let Base = /*#__PURE__*/babelHelpers.createClass(function Base() { Base.prototype.test = 1; let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "get", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-getter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-getter-defined-on-parent/output.js index 37c8f6e501b6..949702c7d9fd 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-getter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-getter-defined-on-parent/output.js @@ -15,10 +15,9 @@ let Base = /*#__PURE__*/function () { }(); let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "get", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-not-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-not-defined-on-parent/output.js index 708f3a54ec41..08e8509a7fd1 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-not-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-not-defined-on-parent/output.js @@ -5,10 +5,9 @@ let Base = /*#__PURE__*/babelHelpers.createClass(function Base() { }); let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "get", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-setter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-setter-defined-on-parent/output.js index 3ff73c04dd96..c360e812f610 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-setter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/get-semantics-setter-defined-on-parent/output.js @@ -14,10 +14,9 @@ let Base = /*#__PURE__*/function () { }(); let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "get", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-assign/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-assign/output.js index 0d08c539677b..f32be8af7af6 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-assign/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-assign/output.js @@ -21,10 +21,9 @@ const proper = { }; let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "assign", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-update/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-update/output.js index 6c7c4a17cb90..ee6a0b1dc7db 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-update/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/memoized-update/output.js @@ -21,10 +21,9 @@ const proper = { }; let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "update", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-data-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-data-defined-on-parent/output.js index d28663bc0622..b44e3746daf2 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-data-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-data-defined-on-parent/output.js @@ -10,10 +10,9 @@ Object.defineProperty(Base.prototype, 'test', { }); let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "set", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js index 3ca45cacd807..4d60b037db7c 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js @@ -15,10 +15,9 @@ let Base = /*#__PURE__*/function () { ; let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "set", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-on-obj/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-on-obj/output.js index 40ff5bc4f14f..25263c2cb8e8 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-on-obj/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-on-obj/output.js @@ -5,10 +5,9 @@ let Base = /*#__PURE__*/babelHelpers.createClass(function Base() { }); let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "set", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/output.js index 0bdb7cc2d6cf..e2844946b514 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/output.js @@ -5,10 +5,9 @@ let Base = /*#__PURE__*/babelHelpers.createClass(function Base() { }); let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "test", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-not-on-obj/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-not-on-obj/output.js index 3da98df06136..3119971e613b 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-not-on-obj/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-not-on-obj/output.js @@ -5,10 +5,9 @@ let Base = /*#__PURE__*/babelHelpers.createClass(function Base() { }); let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "set", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-setter-on-obj/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-setter-on-obj/output.js index 4262800b5e5a..00b565763f2a 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-setter-on-obj/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-not-defined-on-parent-setter-on-obj/output.js @@ -6,10 +6,9 @@ let Base = /*#__PURE__*/babelHelpers.createClass(function Base() { let value = 2; let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "test", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-setter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-setter-defined-on-parent/output.js index acad92aae18b..26985a1a2e57 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-setter-defined-on-parent/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-setter-defined-on-parent/output.js @@ -15,10 +15,9 @@ let Base = /*#__PURE__*/function () { }(); let Obj = /*#__PURE__*/function (_Base) { babelHelpers.inherits(Obj, _Base); - var _super = babelHelpers.createSuper(Obj); function Obj() { babelHelpers.classCallCheck(this, Obj); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Obj, arguments); } babelHelpers.createClass(Obj, [{ key: "set", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/14652/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/14652/output.js index 03b8b6f81a77..50b2efbc9668 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/14652/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/14652/output.js @@ -2,11 +2,10 @@ var C = /*#__PURE__*/function (_P) { "use strict"; babelHelpers.inherits(C, _P); - var _super = babelHelpers.createSuper(C); function C() { var _this; babelHelpers.classCallCheck(this, C); - return _super.call(this, _this = _super.call(this, _this = _super.call(this))); + return babelHelpers.callSuper(this, C, [_this = babelHelpers.callSuper(this, C, [_this = babelHelpers.callSuper(this, C)])]); } return babelHelpers.createClass(C); }(P); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/2663/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/2663/output.js index 809ce8cc1bee..d6aac7dca149 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/2663/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/2663/output.js @@ -10,11 +10,10 @@ var _binarySerializer = babelHelpers.interopRequireDefault(require("./helpers/bi // import ... var Connection = exports["default"] = /*#__PURE__*/function (_EventEmitter) { babelHelpers.inherits(Connection, _EventEmitter); - var _super = babelHelpers.createSuper(Connection); function Connection(endpoint, joinKey, joinData, roomId) { var _this; babelHelpers.classCallCheck(this, Connection); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Connection); _this.isConnected = false; _this.roomId = roomId; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/2694/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/2694/output.js index 7eb18360539f..af55e7e8b66d 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/2694/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/2694/output.js @@ -7,10 +7,9 @@ exports["default"] = void 0; var _BaseFoo2 = babelHelpers.interopRequireDefault(require("./BaseFoo")); var SubFoo = exports["default"] = /*#__PURE__*/function (_BaseFoo) { babelHelpers.inherits(SubFoo, _BaseFoo); - var _super = babelHelpers.createSuper(SubFoo); function SubFoo() { babelHelpers.classCallCheck(this, SubFoo); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, SubFoo, arguments); } babelHelpers.createClass(SubFoo, null, [{ key: "talk", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/2775/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/2775/output.js index 466621432bed..fd703d911a36 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/2775/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/2775/output.js @@ -7,10 +7,9 @@ exports["default"] = void 0; var _react = babelHelpers.interopRequireWildcard(require("react")); var RandomComponent = exports["default"] = /*#__PURE__*/function (_Component) { babelHelpers.inherits(RandomComponent, _Component); - var _super = babelHelpers.createSuper(RandomComponent); function RandomComponent() { babelHelpers.classCallCheck(this, RandomComponent); - return _super.call(this); + return babelHelpers.callSuper(this, RandomComponent); } babelHelpers.createClass(RandomComponent, [{ key: "render", diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/3028/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/3028/output.js index 00aa9148b536..5561a34bfef3 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/3028/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/3028/output.js @@ -9,11 +9,10 @@ var b = /*#__PURE__*/babelHelpers.createClass(function b() { }); var a1 = /*#__PURE__*/function (_b) { babelHelpers.inherits(a1, _b); - var _super = babelHelpers.createSuper(a1); function a1() { var _this; babelHelpers.classCallCheck(this, a1); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, a1); _this.x = function () { return babelHelpers.assertThisInitialized(_this); }; @@ -23,11 +22,10 @@ var a1 = /*#__PURE__*/function (_b) { }(b); var a2 = exports["default"] = /*#__PURE__*/function (_b2) { babelHelpers.inherits(a2, _b2); - var _super2 = babelHelpers.createSuper(a2); function a2() { var _this2; babelHelpers.classCallCheck(this, a2); - _this2 = _super2.call(this); + _this2 = babelHelpers.callSuper(this, a2); _this2.x = function () { return babelHelpers.assertThisInitialized(_this2); }; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/5769/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/5769/output.js index 1d80f80283fc..18e802853f9a 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/5769/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/5769/output.js @@ -16,11 +16,10 @@ var ColorPoint = /*#__PURE__*/function (_Point) { "use strict"; babelHelpers.inherits(ColorPoint, _Point); - var _super = babelHelpers.createSuper(ColorPoint); function ColorPoint() { var _thisSuper, _thisSuper2, _this; babelHelpers.classCallCheck(this, ColorPoint); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, ColorPoint); _this.x = 2; babelHelpers.set((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(ColorPoint.prototype)), "x", 3, _thisSuper, true); expect(_this.x).toBe(3); // A diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/5817/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/5817/output.js index 8f046f7f46f0..c69c1fc0195c 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/5817/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/5817/output.js @@ -2,11 +2,10 @@ var A = /*#__PURE__*/function (_B) { "use strict"; babelHelpers.inherits(A, _B); - var _super = babelHelpers.createSuper(A); function A() { var _this; babelHelpers.classCallCheck(this, A); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, A); _this.arrow1 = function (x) { return x; }; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/8499/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/8499/output.js index 8013417b4095..54263c55b7a7 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/8499/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/8499/output.js @@ -13,10 +13,9 @@ try { "use strict"; babelHelpers.inherits(CustomElement, _HTMLElement); - var _super = babelHelpers.createSuper(CustomElement); function CustomElement() { babelHelpers.classCallCheck(this, CustomElement); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, CustomElement, arguments); } return babelHelpers.createClass(CustomElement); }( /*#__PURE__*/babelHelpers.wrapNativeSuper(HTMLElement)); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/T2494/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/T2494/output.js index ef20bef813f2..5118fd1587eb 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/T2494/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/T2494/output.js @@ -3,10 +3,9 @@ var x = { "use strict"; babelHelpers.inherits(_class, _Foo); - var _super = babelHelpers.createSuper(_class); function _class() { babelHelpers.classCallCheck(this, _class); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, _class, arguments); } return babelHelpers.createClass(_class); }(Foo) diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/T2997/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/T2997/output.js index 8b8cd1e18940..2014476fc67d 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/T2997/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/T2997/output.js @@ -7,11 +7,10 @@ var B = /*#__PURE__*/function (_A) { "use strict"; babelHelpers.inherits(B, _A); - var _super = babelHelpers.createSuper(B); function B() { var _this; babelHelpers.classCallCheck(this, B); - return babelHelpers.possibleConstructorReturn(_this, _this = _super.call(this)); + return babelHelpers.possibleConstructorReturn(_this, _this = babelHelpers.callSuper(this, B)); } return babelHelpers.createClass(B); }(A); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/T7537/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/T7537/output.js index 4d97b25b576f..a928664e8179 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/T7537/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/T7537/output.js @@ -7,11 +7,10 @@ var A = /*#__PURE__*/function (_B) { "use strict"; babelHelpers.inherits(A, _B); - var _super = babelHelpers.createSuper(A); function A(track) { var _this; babelHelpers.classCallCheck(this, A); - if (track !== undefined) _this = _super.call(this, track);else _this = _super.call(this); + if (track !== undefined) _this = babelHelpers.callSuper(this, A, [track]);else _this = babelHelpers.callSuper(this, A); return babelHelpers.possibleConstructorReturn(_this); } return babelHelpers.createClass(A); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/regression-1155/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/regression-1155/output.js index 8e1c4b00564c..66a7516fb372 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/regression-1155/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/regression-1155/output.js @@ -2,14 +2,13 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo(options) { babelHelpers.classCallCheck(this, Foo); var parentOptions = {}; parentOptions.init = function () { this; }; - return _super.call(this, parentOptions); + return babelHelpers.callSuper(this, Foo, [parentOptions]); } return babelHelpers.createClass(Foo); }(Bar); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-class/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-class/output.js index 52326104bafa..9b28a9008484 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-class/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-class/output.js @@ -2,16 +2,15 @@ var Test = /*#__PURE__*/function (_Foo) { "use strict"; babelHelpers.inherits(Test, _Foo); - var _super = babelHelpers.createSuper(Test); function Test() { var _babelHelpers$get; var _thisSuper, _thisSuper2, _thisSuper3, _this; babelHelpers.classCallCheck(this, Test); woops.super.test(); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Test); babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Test.prototype)), "test", _thisSuper).call(_thisSuper); - _this = _super.apply(this, arguments); - _this = _super.call.apply(_super, [this, "test"].concat(Array.prototype.slice.call(arguments))); + _this = babelHelpers.callSuper(this, Test, arguments); + _this = babelHelpers.callSuper(this, Test, ["test"].concat(Array.prototype.slice.call(arguments))); babelHelpers.get((_thisSuper2 = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Test.prototype)), "test", _thisSuper2).apply(_thisSuper2, arguments); (_babelHelpers$get = babelHelpers.get((_thisSuper3 = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Test.prototype)), "test", _thisSuper3)).call.apply(_babelHelpers$get, [_thisSuper3, "test"].concat(Array.prototype.slice.call(arguments))); return _this; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-properties/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-properties/output.js index 945a27a8b616..23eec886858c 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-properties/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-properties/output.js @@ -2,11 +2,10 @@ var Test = /*#__PURE__*/function (_Foo) { "use strict"; babelHelpers.inherits(Test, _Foo); - var _super = babelHelpers.createSuper(Test); function Test() { var _thisSuper, _thisSuper2, _this; babelHelpers.classCallCheck(this, Test); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Test); babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Test.prototype)), "test", _thisSuper); babelHelpers.get((_thisSuper2 = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Test.prototype)), "test", _thisSuper2).whatever; return _this; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-property-optional-chain/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-property-optional-chain/output.js index 64a2ffbd6cb0..704331f796be 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-property-optional-chain/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/accessing-super-property-optional-chain/output.js @@ -2,7 +2,6 @@ var Test = /*#__PURE__*/function (_Foo) { "use strict"; babelHelpers.inherits(Test, _Foo); - var _super = babelHelpers.createSuper(Test); function Test() { var _babelHelpers$get, _babelHelpers$get2; var _thisSuper, _thisSuper2, _this; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/calling-super-properties/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/calling-super-properties/output.js index 6db33a703589..dd6e950cf0eb 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/calling-super-properties/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/calling-super-properties/output.js @@ -2,11 +2,10 @@ var Test = /*#__PURE__*/function (_Foo) { "use strict"; babelHelpers.inherits(Test, _Foo); - var _super = babelHelpers.createSuper(Test); function Test() { var _thisSuper, _thisSuper2, _this; babelHelpers.classCallCheck(this, Test); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Test); babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Test.prototype)), "test", _thisSuper).whatever(); babelHelpers.get((_thisSuper2 = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Test.prototype)), "test", _thisSuper2).call(_thisSuper2); return _this; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/computed-keys-yield-await/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/computed-keys-yield-await/output.js index 091686a622fe..4e5ba5f2e9e7 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/computed-keys-yield-await/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/computed-keys-yield-await/output.js @@ -15,10 +15,9 @@ async function* fn() { "use strict"; babelHelpers.inherits(B, _A); - var _super = babelHelpers.createSuper(B); function B() { babelHelpers.classCallCheck(this, B); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, B, arguments); } babelHelpers.createClass(B, [{ key: _await$, diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/constructor/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/constructor/output.js index a67d56cdede0..576c50603b29 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/constructor/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/constructor/output.js @@ -8,11 +8,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Foo); _this.state = "test"; return _this; } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/delay-arrow-function-for-bare-super-derived/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/delay-arrow-function-for-bare-super-derived/output.js index 9c870040c492..cd214583a702 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/delay-arrow-function-for-bare-super-derived/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/delay-arrow-function-for-bare-super-derived/output.js @@ -2,13 +2,12 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); - return _this = _super.call(this, () => { + return _this = babelHelpers.callSuper(this, Foo, [() => { _this.test; - }); + }]); } return babelHelpers.createClass(Foo); }(Bar); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-2/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-2/output.js index f7bc6e3ca605..5717b503c504 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-2/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-2/output.js @@ -2,11 +2,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); - if (eval("false")) _this = _super.call(this); + if (eval("false")) _this = babelHelpers.callSuper(this, Foo); return babelHelpers.possibleConstructorReturn(_this); } return babelHelpers.createClass(Foo); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-3/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-3/output.js index 0a261f2735da..4e750674cd73 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-3/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-3/output.js @@ -2,11 +2,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); - var fn = () => _this = _super.call(this); + var fn = () => _this = babelHelpers.callSuper(this, Foo); fn(); return babelHelpers.possibleConstructorReturn(_this); } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-4/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-4/output.js index 5ef3f32e31f4..7cf32a391172 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-4/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super-4/output.js @@ -2,11 +2,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); - var fn = () => _this = _super.call(this); + var fn = () => _this = babelHelpers.callSuper(this, Foo); return babelHelpers.possibleConstructorReturn(_this); } return babelHelpers.createClass(Foo); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super/output.js index 79987c77bd26..23bf2c1bf5dd 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-must-call-super/output.js @@ -2,7 +2,6 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-no-primitive-return/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-no-primitive-return/output.js index 039b6a5a6d67..61533bfc283f 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-no-primitive-return/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-no-primitive-return/output.js @@ -2,11 +2,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Foo); return babelHelpers.possibleConstructorReturn(_this, 3); } return babelHelpers.createClass(Foo); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-no-super-return-falsey/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-no-super-return-falsey/output.js index 52c9787cb69a..c0056efb2756 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-no-super-return-falsey/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-no-super-return-falsey/output.js @@ -2,7 +2,6 @@ var Child = /*#__PURE__*/function (_Base) { "use strict"; babelHelpers.inherits(Child, _Base); - var _super = babelHelpers.createSuper(Child); function Child() { var _this; babelHelpers.classCallCheck(this, Child); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-no-super-return-object/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-no-super-return-object/output.js index ede9725bf453..87cae4298277 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-no-super-return-object/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/derived-constructor-no-super-return-object/output.js @@ -2,7 +2,6 @@ var Child = /*#__PURE__*/function (_Base) { "use strict"; babelHelpers.inherits(Child, _Base); - var _super = babelHelpers.createSuper(Child); function Child() { var _this; babelHelpers.classCallCheck(this, Child); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/export-super-class/output.mjs b/packages/babel-plugin-transform-classes/test/fixtures/spec/export-super-class/output.mjs index 7c26e6dddadf..12376d6fbb2e 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/export-super-class/output.mjs +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/export-super-class/output.mjs @@ -1,9 +1,8 @@ var _default = /*#__PURE__*/function (_A) { babelHelpers.inherits(_default, _A); - var _super = babelHelpers.createSuper(_default); function _default() { babelHelpers.classCallCheck(this, _default); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, _default, arguments); } return babelHelpers.createClass(_default); }(A); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/name-collisions-with-class-ref-in-computed-key/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/name-collisions-with-class-ref-in-computed-key/output.js index b42e54798091..b2bf4df265e7 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/name-collisions-with-class-ref-in-computed-key/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/name-collisions-with-class-ref-in-computed-key/output.js @@ -2,11 +2,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _thisSuper, _this; babelHelpers.classCallCheck(this, Foo); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Foo); var X = /*#__PURE__*/function (_ref) { function X() { babelHelpers.classCallCheck(this, X); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/name-collisions-with-class-ref-in-constructor/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/name-collisions-with-class-ref-in-constructor/output.js index c021e36ca25a..c6c31b8325ad 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/name-collisions-with-class-ref-in-constructor/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/name-collisions-with-class-ref-in-constructor/output.js @@ -14,11 +14,10 @@ var Foo = /*#__PURE__*/function (_Base) { "use strict"; babelHelpers.inherits(Foo, _Base); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _thisSuper, _this; babelHelpers.classCallCheck(this, Foo); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Foo); if (true) { var _Foo; babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Foo.prototype)), "method", _thisSuper).call(_thisSuper); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/nested-class-super-call-in-key/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/nested-class-super-call-in-key/output.js index a5c068c073fe..0920324e130b 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/nested-class-super-call-in-key/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/nested-class-super-call-in-key/output.js @@ -10,7 +10,6 @@ var Hello = /*#__PURE__*/babelHelpers.createClass(function Hello() { }); var Outer = /*#__PURE__*/function (_Hello) { babelHelpers.inherits(Outer, _Hello); - var _super = babelHelpers.createSuper(Outer); function Outer() { var _this; babelHelpers.classCallCheck(this, Outer); @@ -25,7 +24,7 @@ var Outer = /*#__PURE__*/function (_Hello) { } }]); return Inner; - }(_this = _super.call(this)); + }(_this = babelHelpers.callSuper(this, Outer)); return babelHelpers.possibleConstructorReturn(_this, new Inner()); } return babelHelpers.createClass(Outer); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/nested-class-super-property-in-key/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/nested-class-super-property-in-key/output.js index 281623b5a787..b08e2995bc29 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/nested-class-super-property-in-key/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/nested-class-super-property-in-key/output.js @@ -14,11 +14,10 @@ var Hello = /*#__PURE__*/function () { }(); var Outer = /*#__PURE__*/function (_Hello) { babelHelpers.inherits(Outer, _Hello); - var _super = babelHelpers.createSuper(Outer); function Outer() { var _thisSuper, _this; babelHelpers.classCallCheck(this, Outer); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Outer); var Inner = /*#__PURE__*/function (_babelHelpers$get$cal) { function Inner() { babelHelpers.classCallCheck(this, Inner); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/nested-object-super-call-in-key/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/nested-object-super-call-in-key/output.js index 39d58e9225f7..f6790db0ca1d 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/nested-object-super-call-in-key/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/nested-object-super-call-in-key/output.js @@ -10,12 +10,11 @@ var Hello = /*#__PURE__*/babelHelpers.createClass(function Hello() { }); var Outer = /*#__PURE__*/function (_Hello) { babelHelpers.inherits(Outer, _Hello); - var _super = babelHelpers.createSuper(Outer); function Outer() { var _this; babelHelpers.classCallCheck(this, Outer); var Inner = { - [_this = _super.call(this)]() { + [_this = babelHelpers.callSuper(this, Outer)]() { return 'hello'; } }; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/nested-object-super-property-in-key/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/nested-object-super-property-in-key/output.js index 8e87d0e1c8dd..ed1d2f77fdb0 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/nested-object-super-property-in-key/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/nested-object-super-property-in-key/output.js @@ -14,11 +14,10 @@ var Hello = /*#__PURE__*/function () { }(); var Outer = /*#__PURE__*/function (_Hello) { babelHelpers.inherits(Outer, _Hello); - var _super = babelHelpers.createSuper(Outer); function Outer() { var _thisSuper, _this; babelHelpers.classCallCheck(this, Outer); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Outer); var Inner = { [babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Outer.prototype)), "toString", _thisSuper).call(_thisSuper)]() { return 'hello'; diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class-anonymous/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class-anonymous/output.js index 2e6d01894d85..ebfb47893bf0 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class-anonymous/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class-anonymous/output.js @@ -2,10 +2,9 @@ var TestEmpty = /*#__PURE__*/function (_ref) { "use strict"; babelHelpers.inherits(TestEmpty, _ref); - var _super = babelHelpers.createSuper(TestEmpty); function TestEmpty() { babelHelpers.classCallCheck(this, TestEmpty); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, TestEmpty, arguments); } return babelHelpers.createClass(TestEmpty); }( /*#__PURE__*/function () { @@ -20,10 +19,9 @@ var TestConstructorOnly = /*#__PURE__*/function (_ref2) { "use strict"; babelHelpers.inherits(TestConstructorOnly, _ref2); - var _super2 = babelHelpers.createSuper(TestConstructorOnly); function TestConstructorOnly() { babelHelpers.classCallCheck(this, TestConstructorOnly); - return _super2.apply(this, arguments); + return babelHelpers.callSuper(this, TestConstructorOnly, arguments); } return babelHelpers.createClass(TestConstructorOnly); }( /*#__PURE__*/function () { @@ -38,10 +36,9 @@ var TestMethodOnly = /*#__PURE__*/function (_ref3) { "use strict"; babelHelpers.inherits(TestMethodOnly, _ref3); - var _super3 = babelHelpers.createSuper(TestMethodOnly); function TestMethodOnly() { babelHelpers.classCallCheck(this, TestMethodOnly); - return _super3.apply(this, arguments); + return babelHelpers.callSuper(this, TestMethodOnly, arguments); } return babelHelpers.createClass(TestMethodOnly); }( /*#__PURE__*/function () { @@ -60,10 +57,9 @@ var TestConstructorAndMethod = /*#__PURE__*/function (_ref4) { "use strict"; babelHelpers.inherits(TestConstructorAndMethod, _ref4); - var _super4 = babelHelpers.createSuper(TestConstructorAndMethod); function TestConstructorAndMethod() { babelHelpers.classCallCheck(this, TestConstructorAndMethod); - return _super4.apply(this, arguments); + return babelHelpers.callSuper(this, TestConstructorAndMethod, arguments); } return babelHelpers.createClass(TestConstructorAndMethod); }( /*#__PURE__*/function () { @@ -82,10 +78,9 @@ var TestMultipleMethods = /*#__PURE__*/function (_ref5) { "use strict"; babelHelpers.inherits(TestMultipleMethods, _ref5); - var _super5 = babelHelpers.createSuper(TestMultipleMethods); function TestMultipleMethods() { babelHelpers.classCallCheck(this, TestMultipleMethods); - return _super5.apply(this, arguments); + return babelHelpers.callSuper(this, TestMultipleMethods, arguments); } return babelHelpers.createClass(TestMultipleMethods); }( /*#__PURE__*/function () { diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class-id-member-expression/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class-id-member-expression/output.js index aa8f821b4713..dcbf2dae54fd 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class-id-member-expression/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class-id-member-expression/output.js @@ -2,10 +2,9 @@ var BaseController = /*#__PURE__*/function (_Chaplin$Controller) { "use strict"; babelHelpers.inherits(BaseController, _Chaplin$Controller); - var _super = babelHelpers.createSuper(BaseController); function BaseController() { babelHelpers.classCallCheck(this, BaseController); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, BaseController, arguments); } return babelHelpers.createClass(BaseController); }(Chaplin.Controller); @@ -13,10 +12,9 @@ var BaseController2 = /*#__PURE__*/function (_Chaplin$Controller$A) { "use strict"; babelHelpers.inherits(BaseController2, _Chaplin$Controller$A); - var _super2 = babelHelpers.createSuper(BaseController2); function BaseController2() { babelHelpers.classCallCheck(this, BaseController2); - return _super2.apply(this, arguments); + return babelHelpers.callSuper(this, BaseController2, arguments); } return babelHelpers.createClass(BaseController2); }(Chaplin.Controller.Another); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class/output.js index 1fa0fa72b09b..4a97dd2bf2b0 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-class/output.js @@ -2,10 +2,9 @@ var Test = /*#__PURE__*/function (_Foo) { "use strict"; babelHelpers.inherits(Test, _Foo); - var _super = babelHelpers.createSuper(Test); function Test() { babelHelpers.classCallCheck(this, Test); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Test, arguments); } return babelHelpers.createClass(Test); }(Foo); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-correct-new-target-without-reflect/exec.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-correct-new-target-without-reflect/exec.js new file mode 100644 index 000000000000..f717b1c3639c --- /dev/null +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-correct-new-target-without-reflect/exec.js @@ -0,0 +1,22 @@ +"use strict"; + +const oldReflect = global.Reflect; +try { + global.Reflect = undefined; + + let NewTarget; + + class A { + constructor() { NewTarget = new.target; } + } + class B extends A {} + + new A(); + expect(NewTarget).toBe(A); + + new B(); + expect(NewTarget).toBe(B); +} finally { + global.Reflect = oldReflect; +} + diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-correct-new-target-without-reflect/options.json b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-correct-new-target-without-reflect/options.json new file mode 100644 index 000000000000..2d2f1e949563 --- /dev/null +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-correct-new-target-without-reflect/options.json @@ -0,0 +1,9 @@ +{ + "plugins": [ + "transform-function-name", + "transform-classes", + "transform-new-target", + "transform-spread", + "transform-block-scoping" + ] +} diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-bare-super-inline/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-bare-super-inline/output.js index ebe2ec2700c4..c4080f792bcf 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-bare-super-inline/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-bare-super-inline/output.js @@ -2,11 +2,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _thisSuper, _this; babelHelpers.classCallCheck(this, Foo); - babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Foo.prototype)), "foo", _thisSuper).call(_thisSuper, _this = _super.call(this)); + babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Foo.prototype)), "foo", _thisSuper).call(_thisSuper, _this = babelHelpers.callSuper(this, Foo)); return _this; } return babelHelpers.createClass(Foo); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-bare-super/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-bare-super/output.js index 3e0cf8bf7c49..95492e0d4004 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-bare-super/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-bare-super/output.js @@ -2,12 +2,11 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _thisSuper, _this; babelHelpers.classCallCheck(this, Foo); babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Foo.prototype)), "foo", _thisSuper).call(_thisSuper); - return _this = _super.call(this); + return _this = babelHelpers.callSuper(this, Foo); } return babelHelpers.createClass(Foo); }(Bar); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda-2/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda-2/output.js index 43f292d4bda3..956b94cb37a0 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda-2/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda-2/output.js @@ -2,13 +2,12 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _thisSuper, _thisSuper2, _this; babelHelpers.classCallCheck(this, Foo); var t = () => babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Foo.prototype)), "test", _thisSuper).call(_thisSuper); babelHelpers.get((_thisSuper2 = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Foo.prototype)), "foo", _thisSuper2).call(_thisSuper2); - return _this = _super.call(this); + return _this = babelHelpers.callSuper(this, Foo); } return babelHelpers.createClass(Foo); }(Bar); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda-3/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda-3/output.js index 157b2e0cb11d..9de0c2e92c2b 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda-3/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda-3/output.js @@ -2,12 +2,11 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _thisSuper, _this; babelHelpers.classCallCheck(this, Foo); var t = () => babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Foo.prototype)), "test", _thisSuper).call(_thisSuper); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Foo); t(); return _this; } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda/output.js index caf63bc8a513..b295c6ec27ca 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-before-in-lambda/output.js @@ -2,12 +2,11 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _thisSuper, _this; babelHelpers.classCallCheck(this, Foo); var t = () => babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Foo.prototype)), "test", _thisSuper).call(_thisSuper); - return _this = _super.call(this); + return _this = babelHelpers.callSuper(this, Foo); } return babelHelpers.createClass(Foo); }(Bar); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-in-prop-exression/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-in-prop-exression/output.js index 59ead584907d..d8fa3e589ef3 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-in-prop-exression/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-in-prop-exression/output.js @@ -2,11 +2,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _thisSuper, _this; babelHelpers.classCallCheck(this, Foo); - babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Foo.prototype)), (_this = _super.call(this)).method, _thisSuper).call(_thisSuper); + babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Foo.prototype)), (_this = babelHelpers.callSuper(this, Foo)).method, _thisSuper).call(_thisSuper); return _this; } return babelHelpers.createClass(Foo); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-spread-args/exec.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-spread-args/exec.js new file mode 100644 index 000000000000..e9607b0a6b0e --- /dev/null +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-spread-args/exec.js @@ -0,0 +1,22 @@ +// test262/test/language/expressions/super/call-spread-err-sngl-err-itr-get-get.js + +var iter = {}; +Object.defineProperty(iter, Symbol.iterator, { + get: function() { + throw new Error("err"); + } +}); + +class Test262ParentClass { + constructor() {} +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super(...iter); + } +} + +expect(()=>{ + new Test262ChildClass(); +}).toThrow("err"); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-2/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-2/output.js index 9715ebe063b5..1a23e22c4291 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-2/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-2/output.js @@ -2,11 +2,10 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); - return _this = _super.call(this, babelHelpers.assertThisInitialized(_this)); + return _this = babelHelpers.callSuper(this, Foo, [babelHelpers.assertThisInitialized(_this)]); } return babelHelpers.createClass(Foo); }(Bar); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-3/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-3/output.js index d79f66a7a9de..d0d205995c05 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-3/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-3/output.js @@ -2,13 +2,12 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); var fn = () => babelHelpers.assertThisInitialized(_this); fn(); - return _this = _super.call(this); + return _this = babelHelpers.callSuper(this, Foo); } return babelHelpers.createClass(Foo); }(Bar); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-4/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-4/output.js index 661362b276a7..8cc733fe2182 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-4/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-4/output.js @@ -2,12 +2,11 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); var fn = () => babelHelpers.assertThisInitialized(_this); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Foo); fn(); return _this; } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-5/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-5/output.js index a303aa5f5740..3b54474aa682 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-5/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes-5/output.js @@ -2,7 +2,6 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes/output.js index 17eac9731620..c0ba129eb27b 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/this-not-allowed-before-super-in-derived-classes/output.js @@ -2,12 +2,11 @@ var Foo = /*#__PURE__*/function (_Bar) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { var _this; babelHelpers.classCallCheck(this, Foo); _this.foo = "bar"; - return _this = _super.call(this); + return _this = babelHelpers.callSuper(this, Foo); } return babelHelpers.createClass(Foo); }(Bar); diff --git a/packages/babel-plugin-transform-function-name/test/fixtures/function-name/modules-3/output.js b/packages/babel-plugin-transform-function-name/test/fixtures/function-name/modules-3/output.js index 6ce1edb5f17c..d0351b2ed5fb 100644 --- a/packages/babel-plugin-transform-function-name/test/fixtures/function-name/modules-3/output.js +++ b/packages/babel-plugin-transform-function-name/test/fixtures/function-name/modules-3/output.js @@ -7,10 +7,9 @@ exports.default = void 0; var _store = require("./store"); let Login = exports.default = /*#__PURE__*/function (_React$Component) { babelHelpers.inherits(Login, _React$Component); - var _super = babelHelpers.createSuper(Login); function Login() { babelHelpers.classCallCheck(this, Login); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Login, arguments); } babelHelpers.createClass(Login, [{ key: "getForm", diff --git a/packages/babel-plugin-transform-parameters/test/fixtures/parameters/rest-nested-iife/output.js b/packages/babel-plugin-transform-parameters/test/fixtures/parameters/rest-nested-iife/output.js index 64ea9462c5ad..238e743bf749 100644 --- a/packages/babel-plugin-transform-parameters/test/fixtures/parameters/rest-nested-iife/output.js +++ b/packages/babel-plugin-transform-parameters/test/fixtures/parameters/rest-nested-iife/output.js @@ -4,10 +4,9 @@ function broken(x) { "use strict"; babelHelpers.inherits(Foo, _Bar); - var _super = babelHelpers.createSuper(Foo); function Foo() { babelHelpers.classCallCheck(this, Foo); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, Foo, arguments); } return babelHelpers.createClass(Foo); }(Bar); diff --git a/packages/babel-plugin-transform-parameters/test/fixtures/regression/6057-expanded/output.js b/packages/babel-plugin-transform-parameters/test/fixtures/regression/6057-expanded/output.js index 4c6269dc29e0..edae895bcea4 100644 --- a/packages/babel-plugin-transform-parameters/test/fixtures/regression/6057-expanded/output.js +++ b/packages/babel-plugin-transform-parameters/test/fixtures/regression/6057-expanded/output.js @@ -7,14 +7,13 @@ exports["default"] = void 0; var _args = babelHelpers.interopRequireDefault(require("utils/url/args")); var App = exports["default"] = /*#__PURE__*/function (_Component) { babelHelpers.inherits(App, _Component); - var _super = babelHelpers.createSuper(App); function App() { var _this; babelHelpers.classCallCheck(this, App); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } - _this = _super.call.apply(_super, [this].concat(args)); + _this = babelHelpers.callSuper(this, App, [].concat(args)); babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "exportType", ''); return _this; } diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/optimisation.react.constant-elements/output.mjs b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/optimisation.react.constant-elements/output.mjs index b1daf1db4d3c..2129ad46ec28 100644 --- a/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/optimisation.react.constant-elements/output.mjs +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/optimisation.react.constant-elements/output.mjs @@ -1,10 +1,9 @@ var _div; let App = /*#__PURE__*/function (_React$Component) { babelHelpers.inherits(App, _React$Component); - var _super = babelHelpers.createSuper(App); function App() { babelHelpers.classCallCheck(this, App); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, App, arguments); } babelHelpers.createClass(App, [{ key: "render", diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/optimisation.react.constant-elements/output.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/optimisation.react.constant-elements/output.js index 6b8a6e3fb817..2c178f5b23d3 100644 --- a/packages/babel-plugin-transform-react-jsx/test/fixtures/react/optimisation.react.constant-elements/output.js +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/react/optimisation.react.constant-elements/output.js @@ -3,10 +3,9 @@ let App = /*#__PURE__*/function (_React$Component) { "use strict"; babelHelpers.inherits(App, _React$Component); - var _super = babelHelpers.createSuper(App); function App() { babelHelpers.classCallCheck(this, App); - return _super.apply(this, arguments); + return babelHelpers.callSuper(this, App, arguments); } babelHelpers.createClass(App, [{ key: "render", diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/regression/12863/output.mjs b/packages/babel-plugin-transform-runtime/test/fixtures/regression/12863/output.mjs index 0aec437f2e28..9d7fb657a5c0 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/regression/12863/output.mjs +++ b/packages/babel-plugin-transform-runtime/test/fixtures/regression/12863/output.mjs @@ -1,22 +1,21 @@ import _Reflect$construct from "@babel/runtime-corejs3/core-js-stable/reflect/construct"; import _createClass from "@babel/runtime-corejs3/helpers/createClass"; import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck"; -import _assertThisInitialized from "@babel/runtime-corejs3/helpers/assertThisInitialized"; -import _inherits from "@babel/runtime-corejs3/helpers/inherits"; import _possibleConstructorReturn from "@babel/runtime-corejs3/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime-corejs3/helpers/getPrototypeOf"; +import _assertThisInitialized from "@babel/runtime-corejs3/helpers/assertThisInitialized"; +import _inherits from "@babel/runtime-corejs3/helpers/inherits"; import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty"; import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat"; -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } +function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } +function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); } let B = /*#__PURE__*/function (_A) { _inherits(B, _A); - var _super = _createSuper(B); function B(...args) { var _context; var _this; _classCallCheck(this, B); - _this = _super.call.apply(_super, _concatInstanceProperty(_context = [this]).call(_context, args)); + _this = _callSuper(this, B, _concatInstanceProperty(_context = []).call(_context, args)); _defineProperty(_assertThisInitialized(_this), "b", 8); return _this; } diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs-useESModules/output.mjs b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs-useESModules/output.mjs index 3987919397e5..e99789d9e433 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs-useESModules/output.mjs +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/corejs-useESModules/output.mjs @@ -1,17 +1,16 @@ import _Reflect$construct from "@babel/runtime-corejs3/core-js-stable/reflect/construct"; import _createClass from "@babel/runtime-corejs3/helpers/esm/createClass"; import _classCallCheck from "@babel/runtime-corejs3/helpers/esm/classCallCheck"; -import _inherits from "@babel/runtime-corejs3/helpers/esm/inherits"; import _possibleConstructorReturn from "@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime-corejs3/helpers/esm/getPrototypeOf"; -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } +import _inherits from "@babel/runtime-corejs3/helpers/esm/inherits"; +function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } +function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); } let Foo = /*#__PURE__*/function (_Bar) { _inherits(Foo, _Bar); - var _super = _createSuper(Foo); function Foo() { _classCallCheck(this, Foo); - return _super.apply(this, arguments); + return _callSuper(this, Foo, arguments); } return _createClass(Foo); }(Bar); diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs-auto/output.js b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs-auto/output.js index 2d0597c5d1bc..b1b1ae14319b 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs-auto/output.js +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs-auto/output.js @@ -1,15 +1,14 @@ var _createClass = require("@babel/runtime/helpers/createClass").default; var _classCallCheck = require("@babel/runtime/helpers/classCallCheck").default; +var _callSuper = require("@babel/runtime/helpers/callSuper").default; var _inherits = require("@babel/runtime/helpers/inherits").default; -var _createSuper = require("@babel/runtime/helpers/createSuper").default; let Foo = /*#__PURE__*/function (_Bar) { "use strict"; _inherits(Foo, _Bar); - var _super = _createSuper(Foo); function Foo() { _classCallCheck(this, Foo); - return _super.apply(this, arguments); + return _callSuper(this, Foo, arguments); } return _createClass(Foo); }(Bar); diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs/output.js b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs/output.js index 2d0597c5d1bc..b1b1ae14319b 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs/output.js +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-cjs/output.js @@ -1,15 +1,14 @@ var _createClass = require("@babel/runtime/helpers/createClass").default; var _classCallCheck = require("@babel/runtime/helpers/classCallCheck").default; +var _callSuper = require("@babel/runtime/helpers/callSuper").default; var _inherits = require("@babel/runtime/helpers/inherits").default; -var _createSuper = require("@babel/runtime/helpers/createSuper").default; let Foo = /*#__PURE__*/function (_Bar) { "use strict"; _inherits(Foo, _Bar); - var _super = _createSuper(Foo); function Foo() { _classCallCheck(this, Foo); - return _super.apply(this, arguments); + return _callSuper(this, Foo, arguments); } return _createClass(Foo); }(Bar); diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs-auto/output.mjs b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs-auto/output.mjs index edcfdb4bbf85..e8082be0b64a 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs-auto/output.mjs +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs-auto/output.mjs @@ -1,16 +1,15 @@ import _createClass from "@babel/runtime/helpers/esm/createClass"; import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; -import _inherits from "@babel/runtime/helpers/esm/inherits"; import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf"; -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } +import _inherits from "@babel/runtime/helpers/esm/inherits"; +function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } +function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); } let Foo = /*#__PURE__*/function (_Bar) { _inherits(Foo, _Bar); - var _super = _createSuper(Foo); function Foo() { _classCallCheck(this, Foo); - return _super.apply(this, arguments); + return _callSuper(this, Foo, arguments); } return _createClass(Foo); }(Bar); diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs/output.mjs b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs/output.mjs index edcfdb4bbf85..e8082be0b64a 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs/output.mjs +++ b/packages/babel-plugin-transform-runtime/test/fixtures/use-options/useESModules-mjs/output.mjs @@ -1,16 +1,15 @@ import _createClass from "@babel/runtime/helpers/esm/createClass"; import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; -import _inherits from "@babel/runtime/helpers/esm/inherits"; import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf"; -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } +import _inherits from "@babel/runtime/helpers/esm/inherits"; +function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } +function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); } let Foo = /*#__PURE__*/function (_Bar) { _inherits(Foo, _Bar); - var _super = _createSuper(Foo); function Foo() { _classCallCheck(this, Foo); - return _super.apply(this, arguments); + return _callSuper(this, Foo, arguments); } return _createClass(Foo); }(Bar); diff --git a/packages/babel-plugin-transform-spread/test/fixtures/spread/super-classes-plugin-after/output.js b/packages/babel-plugin-transform-spread/test/fixtures/spread/super-classes-plugin-after/output.js index 199607ec31aa..56bc6b72545a 100644 --- a/packages/babel-plugin-transform-spread/test/fixtures/spread/super-classes-plugin-after/output.js +++ b/packages/babel-plugin-transform-spread/test/fixtures/spread/super-classes-plugin-after/output.js @@ -2,10 +2,9 @@ let A = /*#__PURE__*/function (_B) { "use strict"; babelHelpers.inherits(A, _B); - var _super = babelHelpers.createSuper(A); function A() { babelHelpers.classCallCheck(this, A); - return _super.call.apply(_super, [this].concat(babelHelpers.toConsumableArray(foo))); + return babelHelpers.callSuper(this, A, babelHelpers.toConsumableArray(foo)); } return babelHelpers.createClass(A); }(B); diff --git a/packages/babel-plugin-transform-spread/test/fixtures/spread/super-classes-plugin-before/output.js b/packages/babel-plugin-transform-spread/test/fixtures/spread/super-classes-plugin-before/output.js index 199607ec31aa..56bc6b72545a 100644 --- a/packages/babel-plugin-transform-spread/test/fixtures/spread/super-classes-plugin-before/output.js +++ b/packages/babel-plugin-transform-spread/test/fixtures/spread/super-classes-plugin-before/output.js @@ -2,10 +2,9 @@ let A = /*#__PURE__*/function (_B) { "use strict"; babelHelpers.inherits(A, _B); - var _super = babelHelpers.createSuper(A); function A() { babelHelpers.classCallCheck(this, A); - return _super.call.apply(_super, [this].concat(babelHelpers.toConsumableArray(foo))); + return babelHelpers.callSuper(this, A, babelHelpers.toConsumableArray(foo)); } return babelHelpers.createClass(A); }(B); diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/parameter-properties-with-class-and-super/output.js b/packages/babel-plugin-transform-typescript/test/fixtures/class/parameter-properties-with-class-and-super/output.js index 66b8853edbd0..18ab300dc38c 100644 --- a/packages/babel-plugin-transform-typescript/test/fixtures/class/parameter-properties-with-class-and-super/output.js +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/parameter-properties-with-class-and-super/output.js @@ -2,11 +2,10 @@ let Employee = /*#__PURE__*/function (_Person) { "use strict"; babelHelpers.inherits(Employee, _Person); - var _super = babelHelpers.createSuper(Employee); function Employee(name) { var _this; babelHelpers.classCallCheck(this, Employee); - _this = _super.call(this); + _this = babelHelpers.callSuper(this, Employee); _this.name = name; return _this; } diff --git a/packages/babel-preset-env/test/fixtures/plugins-integration/issue-7527/output.js b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-7527/output.js index 9a19362ad35a..d8adc0f625ea 100644 --- a/packages/babel-preset-env/test/fixtures/plugins-integration/issue-7527/output.js +++ b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-7527/output.js @@ -2,10 +2,9 @@ var MyDate = /*#__PURE__*/function (_Date) { babelHelpers.inherits(MyDate, _Date); - var _super = babelHelpers.createSuper(MyDate); function MyDate(time) { babelHelpers.classCallCheck(this, MyDate); - return _super.call(this, time); + return babelHelpers.callSuper(this, MyDate, [time]); } return babelHelpers.createClass(MyDate); }( /*#__PURE__*/babelHelpers.wrapNativeSuper(Date)); diff --git a/packages/babel-preset-env/test/fixtures/plugins-integration/spread-super-firefox-40/output.js b/packages/babel-preset-env/test/fixtures/plugins-integration/spread-super-firefox-40/output.js index 2383cca48f00..23f86f325a13 100644 --- a/packages/babel-preset-env/test/fixtures/plugins-integration/spread-super-firefox-40/output.js +++ b/packages/babel-preset-env/test/fixtures/plugins-integration/spread-super-firefox-40/output.js @@ -2,10 +2,9 @@ var A = /*#__PURE__*/function (_B) { "use strict"; babelHelpers.inherits(A, _B); - var _super = babelHelpers.createSuper(A); function A(args) { babelHelpers.classCallCheck(this, A); - return _super.call.apply(_super, [this].concat(babelHelpers.toConsumableArray(args))); + return babelHelpers.callSuper(this, A, babelHelpers.toConsumableArray(args)); } return babelHelpers.createClass(A); }(B); diff --git a/packages/babel-runtime-corejs2/package.json b/packages/babel-runtime-corejs2/package.json index bef286195443..5cd2ba95e783 100644 --- a/packages/babel-runtime-corejs2/package.json +++ b/packages/babel-runtime-corejs2/package.json @@ -108,6 +108,15 @@ "./helpers/awaitAsyncGenerator.js" ], "./helpers/esm/awaitAsyncGenerator": "./helpers/esm/awaitAsyncGenerator.js", + "./helpers/callSuper": [ + { + "node": "./helpers/callSuper.js", + "import": "./helpers/esm/callSuper.js", + "default": "./helpers/callSuper.js" + }, + "./helpers/callSuper.js" + ], + "./helpers/esm/callSuper": "./helpers/esm/callSuper.js", "./helpers/checkInRHS": [ { "node": "./helpers/checkInRHS.js", @@ -117,6 +126,15 @@ "./helpers/checkInRHS.js" ], "./helpers/esm/checkInRHS": "./helpers/esm/checkInRHS.js", + "./helpers/construct": [ + { + "node": "./helpers/construct.js", + "import": "./helpers/esm/construct.js", + "default": "./helpers/construct.js" + }, + "./helpers/construct.js" + ], + "./helpers/esm/construct": "./helpers/esm/construct.js", "./helpers/defineAccessor": [ { "node": "./helpers/defineAccessor.js", @@ -153,6 +171,15 @@ "./helpers/interopRequireWildcard.js" ], "./helpers/esm/interopRequireWildcard": "./helpers/esm/interopRequireWildcard.js", + "./helpers/isNativeReflectConstruct": [ + { + "node": "./helpers/isNativeReflectConstruct.js", + "import": "./helpers/esm/isNativeReflectConstruct.js", + "default": "./helpers/isNativeReflectConstruct.js" + }, + "./helpers/isNativeReflectConstruct.js" + ], + "./helpers/esm/isNativeReflectConstruct": "./helpers/esm/isNativeReflectConstruct.js", "./helpers/iterableToArrayLimit": [ { "node": "./helpers/iterableToArrayLimit.js", @@ -378,24 +405,6 @@ "./helpers/setPrototypeOf.js" ], "./helpers/esm/setPrototypeOf": "./helpers/esm/setPrototypeOf.js", - "./helpers/isNativeReflectConstruct": [ - { - "node": "./helpers/isNativeReflectConstruct.js", - "import": "./helpers/esm/isNativeReflectConstruct.js", - "default": "./helpers/isNativeReflectConstruct.js" - }, - "./helpers/isNativeReflectConstruct.js" - ], - "./helpers/esm/isNativeReflectConstruct": "./helpers/esm/isNativeReflectConstruct.js", - "./helpers/construct": [ - { - "node": "./helpers/construct.js", - "import": "./helpers/esm/construct.js", - "default": "./helpers/construct.js" - }, - "./helpers/construct.js" - ], - "./helpers/esm/construct": "./helpers/esm/construct.js", "./helpers/isNativeFunction": [ { "node": "./helpers/isNativeFunction.js", diff --git a/packages/babel-runtime-corejs3/package.json b/packages/babel-runtime-corejs3/package.json index f4cfa3e385d4..22b90876b67a 100644 --- a/packages/babel-runtime-corejs3/package.json +++ b/packages/babel-runtime-corejs3/package.json @@ -107,6 +107,15 @@ "./helpers/awaitAsyncGenerator.js" ], "./helpers/esm/awaitAsyncGenerator": "./helpers/esm/awaitAsyncGenerator.js", + "./helpers/callSuper": [ + { + "node": "./helpers/callSuper.js", + "import": "./helpers/esm/callSuper.js", + "default": "./helpers/callSuper.js" + }, + "./helpers/callSuper.js" + ], + "./helpers/esm/callSuper": "./helpers/esm/callSuper.js", "./helpers/checkInRHS": [ { "node": "./helpers/checkInRHS.js", @@ -116,6 +125,15 @@ "./helpers/checkInRHS.js" ], "./helpers/esm/checkInRHS": "./helpers/esm/checkInRHS.js", + "./helpers/construct": [ + { + "node": "./helpers/construct.js", + "import": "./helpers/esm/construct.js", + "default": "./helpers/construct.js" + }, + "./helpers/construct.js" + ], + "./helpers/esm/construct": "./helpers/esm/construct.js", "./helpers/defineAccessor": [ { "node": "./helpers/defineAccessor.js", @@ -152,6 +170,15 @@ "./helpers/interopRequireWildcard.js" ], "./helpers/esm/interopRequireWildcard": "./helpers/esm/interopRequireWildcard.js", + "./helpers/isNativeReflectConstruct": [ + { + "node": "./helpers/isNativeReflectConstruct.js", + "import": "./helpers/esm/isNativeReflectConstruct.js", + "default": "./helpers/isNativeReflectConstruct.js" + }, + "./helpers/isNativeReflectConstruct.js" + ], + "./helpers/esm/isNativeReflectConstruct": "./helpers/esm/isNativeReflectConstruct.js", "./helpers/iterableToArrayLimit": [ { "node": "./helpers/iterableToArrayLimit.js", @@ -377,24 +404,6 @@ "./helpers/setPrototypeOf.js" ], "./helpers/esm/setPrototypeOf": "./helpers/esm/setPrototypeOf.js", - "./helpers/isNativeReflectConstruct": [ - { - "node": "./helpers/isNativeReflectConstruct.js", - "import": "./helpers/esm/isNativeReflectConstruct.js", - "default": "./helpers/isNativeReflectConstruct.js" - }, - "./helpers/isNativeReflectConstruct.js" - ], - "./helpers/esm/isNativeReflectConstruct": "./helpers/esm/isNativeReflectConstruct.js", - "./helpers/construct": [ - { - "node": "./helpers/construct.js", - "import": "./helpers/esm/construct.js", - "default": "./helpers/construct.js" - }, - "./helpers/construct.js" - ], - "./helpers/esm/construct": "./helpers/esm/construct.js", "./helpers/isNativeFunction": [ { "node": "./helpers/isNativeFunction.js", diff --git a/packages/babel-runtime/package.json b/packages/babel-runtime/package.json index 902858df9bc4..0ebfbcd23481 100644 --- a/packages/babel-runtime/package.json +++ b/packages/babel-runtime/package.json @@ -107,6 +107,15 @@ "./helpers/awaitAsyncGenerator.js" ], "./helpers/esm/awaitAsyncGenerator": "./helpers/esm/awaitAsyncGenerator.js", + "./helpers/callSuper": [ + { + "node": "./helpers/callSuper.js", + "import": "./helpers/esm/callSuper.js", + "default": "./helpers/callSuper.js" + }, + "./helpers/callSuper.js" + ], + "./helpers/esm/callSuper": "./helpers/esm/callSuper.js", "./helpers/checkInRHS": [ { "node": "./helpers/checkInRHS.js", @@ -116,6 +125,15 @@ "./helpers/checkInRHS.js" ], "./helpers/esm/checkInRHS": "./helpers/esm/checkInRHS.js", + "./helpers/construct": [ + { + "node": "./helpers/construct.js", + "import": "./helpers/esm/construct.js", + "default": "./helpers/construct.js" + }, + "./helpers/construct.js" + ], + "./helpers/esm/construct": "./helpers/esm/construct.js", "./helpers/defineAccessor": [ { "node": "./helpers/defineAccessor.js", @@ -152,6 +170,15 @@ "./helpers/interopRequireWildcard.js" ], "./helpers/esm/interopRequireWildcard": "./helpers/esm/interopRequireWildcard.js", + "./helpers/isNativeReflectConstruct": [ + { + "node": "./helpers/isNativeReflectConstruct.js", + "import": "./helpers/esm/isNativeReflectConstruct.js", + "default": "./helpers/isNativeReflectConstruct.js" + }, + "./helpers/isNativeReflectConstruct.js" + ], + "./helpers/esm/isNativeReflectConstruct": "./helpers/esm/isNativeReflectConstruct.js", "./helpers/iterableToArrayLimit": [ { "node": "./helpers/iterableToArrayLimit.js", @@ -377,24 +404,6 @@ "./helpers/setPrototypeOf.js" ], "./helpers/esm/setPrototypeOf": "./helpers/esm/setPrototypeOf.js", - "./helpers/isNativeReflectConstruct": [ - { - "node": "./helpers/isNativeReflectConstruct.js", - "import": "./helpers/esm/isNativeReflectConstruct.js", - "default": "./helpers/isNativeReflectConstruct.js" - }, - "./helpers/isNativeReflectConstruct.js" - ], - "./helpers/esm/isNativeReflectConstruct": "./helpers/esm/isNativeReflectConstruct.js", - "./helpers/construct": [ - { - "node": "./helpers/construct.js", - "import": "./helpers/esm/construct.js", - "default": "./helpers/construct.js" - }, - "./helpers/construct.js" - ], - "./helpers/esm/construct": "./helpers/esm/construct.js", "./helpers/isNativeFunction": [ { "node": "./helpers/isNativeFunction.js", diff --git a/yarn.lock b/yarn.lock index 3482aa3c2ef2..b314295a2938 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2507,7 +2507,6 @@ __metadata: "@babel/helper-compilation-targets": "workspace:^" "@babel/helper-environment-visitor": "workspace:^" "@babel/helper-function-name": "workspace:^" - "@babel/helper-optimise-call-expression": "workspace:^" "@babel/helper-plugin-test-runner": "workspace:^" "@babel/helper-plugin-utils": "workspace:^" "@babel/helper-replace-supers": "workspace:^"