diff --git a/packages/babel-helpers/src/helpers-generated.ts b/packages/babel-helpers/src/helpers-generated.ts index 951447f2db43..bf6e18ef9d7f 100644 --- a/packages/babel-helpers/src/helpers-generated.ts +++ b/packages/babel-helpers/src/helpers-generated.ts @@ -23,7 +23,7 @@ export default Object.freeze({ ), applyDecs: helper( "7.17.8", - 'function old_createMetadataMethodsForProperty(e,t,a,r){return{getMetadata:function(o){old_assertNotFinished(r,"getMetadata"),old_assertMetadataKey(o);var i=e[o];if(void 0!==i)if(1===t){var n=i.public;if(void 0!==n)return n[a]}else if(2===t){var l=i.private;if(void 0!==l)return l.get(a)}else if(Object.hasOwnProperty.call(i,"constructor"))return i.constructor},setMetadata:function(o,i){old_assertNotFinished(r,"setMetadata"),old_assertMetadataKey(o);var n=e[o];if(void 0===n&&(n=e[o]={}),1===t){var l=n.public;void 0===l&&(l=n.public={}),l[a]=i}else if(2===t){var s=n.priv;void 0===s&&(s=n.private=new Map),s.set(a,i)}else n.constructor=i}}}function old_convertMetadataMapToFinal(e,t){var a=e[Symbol.metadata||Symbol.for("Symbol.metadata")],r=Object.getOwnPropertySymbols(t);if(0!==r.length){for(var o=0;o=0;y--){var b;if(void 0!==(f=old_memberDec(h[y],r,c,l,s,o,i,n,u)))old_assertValidReturnValue(o,f),0===o?b=f:1===o?(b=old_getInit(f),p=f.get||u.get,v=f.set||u.set,u={get:p,set:v}):u=f,void 0!==b&&(void 0===d?d=b:"function"==typeof d?d=[d,b]:d.push(b))}if(0===o||1===o){if(void 0===d)d=function(e,t){return t};else if("function"!=typeof d){var g=d;d=function(e,t){for(var a=t,r=0;r3,b=v>=5;if(b?(u=t,f=r,0!==(v-=5)&&(p=n=n||[])):(u=t.prototype,f=a,0!==v&&(p=i=i||[])),0!==v&&!y){var g=b?s:l,m=g.get(h)||0;if(!0===m||3===m&&4!==v||4===m&&3!==v)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: "+h);!m&&v>2?g.set(h,v):g.set(h,!0)}old_applyMemberDec(e,u,d,h,v,b,y,f,p)}}old_pushInitializers(e,i),old_pushInitializers(e,n)}function old_pushInitializers(e,t){t&&e.push((function(e){for(var a=0;a0){for(var o=[],i=t,n=t.name,l=r.length-1;l>=0;l--){var s={v:!1};try{var c=Object.assign({kind:"class",name:n,addInitializer:old_createAddInitializerMethod(o,s)},old_createMetadataMethodsForProperty(a,0,n,s)),d=r[l](i,c)}finally{s.v=!0}void 0!==d&&(old_assertValidReturnValue(10,d),i=d)}e.push(i,(function(){for(var e=0;e=0;h--){var b;if(void 0!==(f=old_memberDec(y[h],a,c,l,s,o,i,n,u)))old_assertValidReturnValue(o,f),0===o?b=f:1===o?(b=old_getInit(f),p=f.get||u.get,v=f.set||u.set,u={get:p,set:v}):u=f,void 0!==b&&(void 0===d?d=b:"function"==typeof d?d=[d,b]:d.push(b))}if(0===o||1===o){if(void 0===d)d=function(e,t){return t};else if("function"!=typeof d){var g=d;d=function(e,t){for(var r=t,a=0;a3,b=v>=5;if(b?(u=t,f=a,0!==(v-=5)&&(p=n=n||[])):(u=t.prototype,f=r,0!==v&&(p=i=i||[])),0!==v&&!h){var g=b?s:l,m=g.get(y)||0;if(!0===m||3===m&&4!==v||4===m&&3!==v)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: "+y);!m&&v>2?g.set(y,v):g.set(y,!0)}old_applyMemberDec(e,u,d,y,v,b,h,f,p)}}old_pushInitializers(e,i),old_pushInitializers(e,n)}function old_pushInitializers(e,t){t&&e.push((function(e){for(var r=0;r0){for(var o=[],i=t,n=t.name,l=a.length-1;l>=0;l--){var s={v:!1};try{var c=Object.assign({kind:"class",name:n,addInitializer:old_createAddInitializerMethod(o,s)},old_createMetadataMethodsForProperty(r,0,n,s)),d=a[l](i,c)}finally{s.v=!0}void 0!==d&&(old_assertValidReturnValue(10,d),i=d)}e.push(i,(function(){for(var e=0;e=0;v--){var g;if(void 0!==(f=memberDec(h[v],n,c,o,a,i,s,u)))assertValidReturnValue(a,f),0===a?g=f:1===a?(g=f.init,p=f.get||u.get,d=f.set||u.set,u={get:p,set:d}):u=f,void 0!==g&&(void 0===l?l=g:"function"==typeof l?l=[l,g]:l.push(g))}if(0===a||1===a){if(void 0===l)l=function(e,t){return t};else if("function"!=typeof l){var y=l;l=function(e,t){for(var r=t,n=0;n3,h=f>=5;if(h?(l=e,0!==(f-=5)&&(u=n=n||[])):(l=e.prototype,0!==f&&(u=r=r||[])),0!==f&&!d){var v=h?s:i,g=v.get(p)||0;if(!0===g||3===g&&4!==f||4===g&&3!==f)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: "+p);!g&&f>2?v.set(p,f):v.set(p,!0)}applyMemberDec(a,l,c,p,f,h,d,u)}}return pushInitializers(a,r),pushInitializers(a,n),a}function pushInitializers(e,t){t&&e.push((function(e){for(var r=0;r0){for(var r=[],n=e,a=e.name,i=t.length-1;i>=0;i--){var s={v:!1};try{var o=t[i](n,{kind:"class",name:a,addInitializer:createAddInitializerMethod(r,s)})}finally{s.v=!0}void 0!==o&&(assertValidReturnValue(10,o),n=o)}return[n,function(){for(var e=0;e=0;v--){var y;if(void 0!==(f=memberDec(h[v],n,c,s,a,i,o,u)))assertValidReturnValue(a,f),0===a?y=f:1===a?(y=f.init,p=f.get||u.get,d=f.set||u.set,u={get:p,set:d}):u=f,void 0!==y&&(void 0===l?l=y:"function"==typeof l?l=[l,y]:l.push(y))}if(0===a||1===a){if(void 0===l)l=function(e,t){return t};else if("function"!=typeof l){var g=l;l=function(e,t){for(var r=t,n=0;n3,h=f>=5;if(h?(l=e,0!==(f-=5)&&(u=n=n||[])):(l=e.prototype,0!==f&&(u=r=r||[])),0!==f&&!d){var v=h?o:i,y=v.get(p)||0;if(!0===y||3===y&&4!==f||4===y&&3!==f)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: "+p);!y&&f>2?v.set(p,f):v.set(p,!0)}applyMemberDec(a,l,c,p,f,h,d,u)}}return pushInitializers(a,r),pushInitializers(a,n),a}function pushInitializers(e,t){t&&e.push((function(e){for(var r=0;r0){for(var r=[],n=e,a=e.name,i=t.length-1;i>=0;i--){var o={v:!1};try{var s=t[i](n,{kind:"class",name:a,addInitializer:createAddInitializerMethod(r,o)})}finally{o.v=!0}void 0!==s&&(assertValidReturnValue(10,s),n=s)}return[n,function(){for(var e=0;e=0;y--){var m;if(void 0!==(d=memberDec(g[y],n,u,o,a,i,s,f,c)))assertValidReturnValue(a,d),0===a?m=d:1===a?(m=d.init,h=d.get||f.get,v=d.set||f.set,f={get:h,set:v}):f=d,void 0!==m&&(void 0===l?l=m:"function"==typeof l?l=[l,m]:l.push(m))}if(0===a||1===a){if(void 0===l)l=function(e,t){return t};else if("function"!=typeof l){var b=l;l=function(e,t){for(var r=t,n=0;n3,g=d>=5,y=r;if(g?(f=e,0!==(d-=5)&&(p=a=a||[]),v&&!i&&(i=function(t){return checkInRHS(t)===e}),y=i):(f=e.prototype,0!==d&&(p=n=n||[])),0!==d&&!v){var m=g?c:o,b=m.get(h)||0;if(!0===b||3===b&&4!==d||4===b&&3!==d)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: "+h);!b&&d>2?m.set(h,d):m.set(h,!0)}applyMemberDec(s,f,l,h,d,g,v,p,y)}}return pushInitializers(s,n),pushInitializers(s,a),s}function pushInitializers(e,t){t&&e.push((function(e){for(var r=0;r0){for(var r=[],n=e,a=e.name,i=t.length-1;i>=0;i--){var s={v:!1};try{var o=t[i](n,{kind:"class",name:a,addInitializer:createAddInitializerMethod(r,s)})}finally{s.v=!0}void 0!==o&&(assertValidReturnValue(10,o),n=o)}return[n,function(){for(var e=0;e=0;g--){var m;if(void 0!==(d=memberDec(y[g],n,u,o,a,i,s,f,c)))assertValidReturnValue(a,d),0===a?m=d:1===a?(m=d.init,h=d.get||f.get,v=d.set||f.set,f={get:h,set:v}):f=d,void 0!==m&&(void 0===l?l=m:"function"==typeof l?l=[l,m]:l.push(m))}if(0===a||1===a){if(void 0===l)l=function(e,t){return t};else if("function"!=typeof l){var b=l;l=function(e,t){for(var r=t,n=0;n3,y=d>=5,g=r;if(y?(f=e,0!==(d-=5)&&(p=a=a||[]),v&&!i&&(i=function(t){return checkInRHS(t)===e}),g=i):(f=e.prototype,0!==d&&(p=n=n||[])),0!==d&&!v){var m=y?c:o,b=m.get(h)||0;if(!0===b||3===b&&4!==d||4===b&&3!==d)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: "+h);!b&&d>2?m.set(h,d):m.set(h,!0)}applyMemberDec(s,f,l,h,d,y,v,p,g)}}return pushInitializers(s,n),pushInitializers(s,a),s}function pushInitializers(e,t){t&&e.push((function(e){for(var r=0;r0){for(var r=[],n=e,a=e.name,i=t.length-1;i>=0;i--){var s={v:!1};try{var o=t[i](n,{kind:"class",name:a,addInitializer:createAddInitializerMethod(r,s)})}finally{s.v=!0}void 0!==o&&(assertValidReturnValue(10,o),n=o)}return[n,function(){for(var e=0;e=0;y-=b){var g;if(void 0!==(v=memberDec(h[y],a?h[y-1]:void 0,n,f,l,i,o,s,p,c,u)))assertValidReturnValue(i,v),0===i?g=v:1===i?(g=v.init,p={get:v.get||p.get,set:v.set||p.set}):p=v,void 0!==g&&(void 0===d?d=g:"function"==typeof d?d=[d,g]:d.push(g))}if(0===i||1===i){if(void 0===d)d=function(e,t){return t};else if("function"!=typeof d){var I=d;d=function(e,t){for(var r=t,a=I.length-1;a>=0;a--)r=I[a].call(e,r);return r}}else{var w=d;d=d.call.bind(w)}e.push(d)}0!==i&&(1===i?(f.get=p.get,f.set=p.set):2===i?f.value=p:3===i?f.get=p:4===i&&(f.set=p),s?1===i?e.push(_bindPropCall(f,"get"),_bindPropCall(f,"set")):e.push(2===i?p:Function.call.bind(p)):Object.defineProperty(t,n,f))}function applyMemberDecs(e,t,r,a){var n,i,o,s=[],l=new Map,c=new Map;function pushInitializers(e){e&&s.push((function(t){for(var r=0;r3,b=16&v,y=!!(8&v),g=r;if(v&=7,y?(d=e,p=i=i||[],m&&!o&&(o=function(t){return checkInRHS(t)===e}),g=o):(d=e.prototype,p=n=n||[]),0!==v&&!m){var I=y?c:l,w=I.get(h)||0;if(!0===w||3===w&&4!==v||4===w&&3!==v)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: "+h);I.set(h,!(!w&&v>2)||v)}applyMemberDec(s,d,f,b,h,v,y,m,p,g,a)}}return pushInitializers(n),pushInitializers(i),s}function applyClassDecs(e,t,r,a){if(t.length){for(var n=[],i=e,o=e.name,s=r?2:1,l=t.length-1;l>=0;l-=s){var c={v:!1};try{var u=t[l].call(r?t[l-1]:void 0,i,{kind:"class",name:o,addInitializer:createAddInitializerMethod(n,c),metadata:a})}finally{c.v=!0}void 0!==u&&(assertValidReturnValue(5,u),i=u)}return[defineMetadata(i,a),function(){for(var e=0;e=6)var o=i[Symbol.metadata||Symbol.for("Symbol.metadata")];var s=Object.create(void 0===o?null:o),l=applyMemberDecs(e,t,n,s);return r.length||defineMetadata(e,s),{e:l,get c(){return applyClassDecs(e,r,a,s)}}}', + 'import checkInRHS from"checkInRHS";import toPropertyKey from"toPropertyKey";function _bindPropCall(e,t){return function(r,a){return e[t].call(r,a)}}function createAddInitializerMethod(e,t){return function(r){if(t.v)throw new Error("attempted to call addInitializer after decoration was finished");assertCallable(r,"An initializer",!0),e.push(r)}}function memberDec(e,t,r,a,n,i,o,s,l,c,u){function assertInstanceIfPrivate(e){return function(t,r){if(!c(t))throw new TypeError("Attempted to access private element on non-instance");return e(t,r)}}var f,d,p={v:!1},v={kind:["field","accessor","method","getter","setter","field"][i],name:s?"#"+r:toPropertyKey(r),static:o,private:s,metadata:u,addInitializer:createAddInitializerMethod(n,p)};if(s||0!==i&&2!==i)if(2===i)f=assertInstanceIfPrivate((function(){return a.value}));else{var h=0===i||1===i;(h||3===i)&&(f=_bindPropCall(a,"get"),s&&(f=assertInstanceIfPrivate(f))),(h||4===i)&&(d=_bindPropCall(a,"set"),s&&(d=assertInstanceIfPrivate(d)))}else f=function(e){return e[r]},0===i&&(d=function(e,t){e[r]=t});var y=s?c.bind():function(e){return r in e},m=v.access={has:y};f&&(m.get=f),d&&(m.set=d);try{return e.call(t,l,v)}finally{p.v=!0}}function assertCallable(e,t,r){if("function"!=typeof e&&(r||void 0!==e))throw new TypeError(t+" must be a function")}function assertValidReturnValue(e,t){var r=typeof t;if(1===e){if("object"!==r||!t)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");assertCallable(t.get,"accessor.get"),assertCallable(t.set,"accessor.set"),assertCallable(t.init,"accessor.init")}else if("function"!==r)throw new TypeError((0===e?"field":5===e?"class":"method")+" decorators must return a function or void 0")}function applyMemberDec(e,t,r,a,n,i,o,s,l,c,u){var f,d,p,v,h=r[0],y=r[3];a||Array.isArray(h)||(h=[h]),s?f=0===i||1===i?{get:function(){return y(this)},set:function(e){r[4](this,e)}}:3===i?{get:y}:4===i?{set:y}:{value:y}:0!==i&&(f=Object.getOwnPropertyDescriptor(t,n)),1===i?p={get:f.get,set:f.set}:2===i?p=f.value:3===i?p=f.get:4===i&&(p=f.set);for(var m=a?2:1,b=h.length-1;b>=0;b-=m){var g;if(void 0!==(v=memberDec(h[b],a?h[b-1]:void 0,n,f,l,i,o,s,p,c,u)))assertValidReturnValue(i,v),0===i?g=v:1===i?(g=v.init,p={get:v.get||p.get,set:v.set||p.set}):p=v,void 0!==g&&(void 0===d?d=g:"function"==typeof d?d=[d,g]:d.push(g))}if(0===i||1===i){if(void 0===d)d=function(e,t){return t};else if("function"!=typeof d){var I=d;d=function(e,t){for(var r=t,a=I.length-1;a>=0;a--)r=I[a].call(e,r);return r}}else{var w=d;d=d.call.bind(w)}e.push(d)}0!==i&&(1===i?(f.get=p.get,f.set=p.set):2===i?f.value=p:3===i?f.get=p:4===i&&(f.set=p),s?1===i?e.push(_bindPropCall(f,"get"),_bindPropCall(f,"set")):e.push(2===i?p:Function.call.bind(p)):Object.defineProperty(t,n,f))}function applyMemberDecs(e,t,r,a){var n,i,o,s=[],l=new Map,c=new Map;function pushInitializers(e){e&&s.push((function(t){for(var r=0;r3,m=16&v,b=!!(8&v),g=r;if(v&=7,b?(d=e,p=i=i||[],y&&!o&&(o=function(t){return checkInRHS(t)===e}),g=o):(d=e.prototype,p=n=n||[]),0!==v&&!y){var I=b?c:l,w=I.get(h)||0;if(!0===w||3===w&&4!==v||4===w&&3!==v)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: "+h);I.set(h,!(!w&&v>2)||v)}applyMemberDec(s,d,f,m,h,v,b,y,p,g,a)}}return pushInitializers(n),pushInitializers(i),s}function applyClassDecs(e,t,r,a){if(t.length){for(var n=[],i=e,o=e.name,s=r?2:1,l=t.length-1;l>=0;l-=s){var c={v:!1};try{var u=t[l].call(r?t[l-1]:void 0,i,{kind:"class",name:o,addInitializer:createAddInitializerMethod(n,c),metadata:a})}finally{c.v=!0}void 0!==u&&(assertValidReturnValue(5,u),i=u)}return[defineMetadata(i,a),function(){for(var e=0;e=6)var o=i[Symbol.metadata||Symbol.for("Symbol.metadata")];var s=Object.create(void 0===o?null:o),l=applyMemberDecs(e,t,n,s);return r.length||defineMetadata(e,s),{e:l,get c(){return applyClassDecs(e,r,a,s)}}}', ), asyncGeneratorDelegate: helper( "7.0.0-beta.0", @@ -93,6 +93,14 @@ export default Object.freeze({ "7.18.0", 'export default function _regeneratorRuntime(){"use strict";\n/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_regeneratorRuntime=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function define(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{define({},"")}catch(t){define=function(t,e,r){return t[e]=r}}function wrap(t,e,r,n){var i=e&&e.prototype instanceof Generator?e:Generator,a=Object.create(i.prototype),c=new Context(n||[]);return o(a,"_invoke",{value:makeInvokeMethod(t,r,c)}),a}function tryCatch(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=wrap;var h="suspendedStart",l="suspendedYield",f="executing",s="completed",y={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,a,(function(){return this}));var d=Object.getPrototypeOf,v=d&&d(d(values([])));v&&v!==r&&n.call(v,a)&&(p=v);var g=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(e){define(t,e,(function(t){return this._invoke(e,t)}))}))}function AsyncIterator(t,e){function invoke(r,o,i,a){var c=tryCatch(t[r],t,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then((function(t){invoke("next",t,i,a)}),(function(t){invoke("throw",t,i,a)})):e.resolve(h).then((function(t){u.value=t,i(u)}),(function(t){return invoke("throw",t,i,a)}))}a(c.arg)}var r;o(this,"_invoke",{value:function(t,n){function callInvokeWithMethodAndArg(){return new e((function(e,r){invoke(t,n,e,r)}))}return r=r?r.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}})}function makeInvokeMethod(e,r,n){var o=h;return function(i,a){if(o===f)throw new Error("Generator is already running");if(o===s){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=maybeInvokeDelegate(c,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=s,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=f;var p=tryCatch(e,r,n);if("normal"===p.type){if(o=n.done?s:l,p.arg===y)continue;return{value:p.arg,done:n.done}}"throw"===p.type&&(o=s,n.method="throw",n.arg=p.arg)}}}function maybeInvokeDelegate(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,maybeInvokeDelegate(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a \'"+n+"\' method")),y;var i=tryCatch(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function pushTryEntry(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function resetTryEntry(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function next(){for(;++o=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),resetTryEntry(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;resetTryEntry(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:values(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}', ), + toPrimitive: helper( + "7.1.5", + 'export default function toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}', + ), + toPropertyKey: helper( + "7.1.5", + 'import toPrimitive from"toPrimitive";export default function toPropertyKey(t){var i=toPrimitive(t,"string");return"symbol"==typeof i?i:String(i)}', + ), typeof: helper( "7.0.0-beta.0", 'export default function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}', diff --git a/packages/babel-helpers/src/helpers.ts b/packages/babel-helpers/src/helpers.ts index 957e61e634c5..07208d7ab6d2 100644 --- a/packages/babel-helpers/src/helpers.ts +++ b/packages/babel-helpers/src/helpers.ts @@ -865,31 +865,6 @@ helpers.skipFirstGeneratorNext = helper("7.0.0-beta.0")` } `; -helpers.toPrimitive = helper("7.1.5")` - export default function _toPrimitive( - input, - hint /*: "default" | "string" | "number" | void */ - ) { - if (typeof input !== "object" || input === null) return input; - var prim = input[Symbol.toPrimitive]; - if (prim !== undefined) { - var res = prim.call(input, hint || "default"); - if (typeof res !== "object") return res; - throw new TypeError("@@toPrimitive must return a primitive value."); - } - return (hint === "string" ? String : Number)(input); - } -`; - -helpers.toPropertyKey = helper("7.1.5")` - import toPrimitive from "toPrimitive"; - - export default function _toPropertyKey(arg) { - var key = toPrimitive(arg, "string"); - return typeof key === "symbol" ? key : String(key); - } -`; - /** * Add a helper that will throw a useful error if the transform fails to detect the class * property assignment, so users know something failed. diff --git a/packages/babel-helpers/src/helpers/applyDecs.js b/packages/babel-helpers/src/helpers/applyDecs.js index 371241d2d291..b2b97f52e4da 100644 --- a/packages/babel-helpers/src/helpers/applyDecs.js +++ b/packages/babel-helpers/src/helpers/applyDecs.js @@ -1,5 +1,6 @@ /* @minVersion 7.17.8 */ +import toPropertyKey from "toPropertyKey"; /** * NOTE: This is an old version of the helper, used for 2021-12 decorators. * Updates should be done in applyDecs2203R.js. @@ -168,7 +169,7 @@ function old_memberDec( var ctx = { kind: kindStr, - name: isPrivate ? "#" + name : name, + name: isPrivate ? "#" + name : toPropertyKey(name), isStatic: isStatic, isPrivate: isPrivate, }; diff --git a/packages/babel-helpers/src/helpers/applyDecs2203R.js b/packages/babel-helpers/src/helpers/applyDecs2203R.js index 5efba8b0e932..574ba96d4586 100644 --- a/packages/babel-helpers/src/helpers/applyDecs2203R.js +++ b/packages/babel-helpers/src/helpers/applyDecs2203R.js @@ -1,5 +1,7 @@ /* @minVersion 7.20.0 */ +import toPropertyKey from "toPropertyKey"; + /** Enums are used in this file, but not assigned to vars to avoid non-hoistable values @@ -58,7 +60,7 @@ function applyDecs2203RFactory() { var ctx = { kind: kindStr, - name: isPrivate ? "#" + name : name, + name: isPrivate ? "#" + name : toPropertyKey(name), static: isStatic, private: isPrivate, }; diff --git a/packages/babel-helpers/src/helpers/applyDecs2301.js b/packages/babel-helpers/src/helpers/applyDecs2301.js index 245d90d2dda6..4db1649479c5 100644 --- a/packages/babel-helpers/src/helpers/applyDecs2301.js +++ b/packages/babel-helpers/src/helpers/applyDecs2301.js @@ -1,6 +1,7 @@ /* @minVersion 7.21.0 */ import checkInRHS from "checkInRHS"; +import toPropertyKey from "toPropertyKey"; /** Enums are used in this file, but not assigned to vars to avoid non-hoistable values @@ -69,7 +70,7 @@ function applyDecs2301Factory() { var ctx = { kind: kindStr, - name: isPrivate ? "#" + name : name, + name: isPrivate ? "#" + name : toPropertyKey(name), static: isStatic, private: isPrivate, }; diff --git a/packages/babel-helpers/src/helpers/applyDecs2305.ts b/packages/babel-helpers/src/helpers/applyDecs2305.ts index 6813db79de3f..f6b893e10e77 100644 --- a/packages/babel-helpers/src/helpers/applyDecs2305.ts +++ b/packages/babel-helpers/src/helpers/applyDecs2305.ts @@ -2,6 +2,8 @@ // @ts-expect-error helper import checkInRHS from "checkInRHS"; +// @ts-expect-error helper +import toPropertyKey from "toPropertyKey"; /** Enums are used in this file, but not assigned to vars to avoid non-hoistable values @@ -94,7 +96,7 @@ function memberDec( kind ] as any, - name: isPrivate ? "#" + name : name, + name: isPrivate ? "#" + name : toPropertyKey(name), static: isStatic, private: isPrivate, metadata: metadata, diff --git a/packages/babel-helpers/src/helpers/toPrimitive.ts b/packages/babel-helpers/src/helpers/toPrimitive.ts new file mode 100644 index 000000000000..fc8dc1a75849 --- /dev/null +++ b/packages/babel-helpers/src/helpers/toPrimitive.ts @@ -0,0 +1,17 @@ +/* @minVersion 7.1.5 */ + +// https://tc39.es/ecma262/#sec-toprimitive +export default function toPrimitive( + input: unknown, + hint: "default" | "string" | "number" | void, +) { + if (typeof input !== "object" || !input) return input; + // @ts-expect-error Symbol.toPrimitive might not index {} + var prim = input[Symbol.toPrimitive]; + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (hint === "string" ? String : Number)(input); +} diff --git a/packages/babel-helpers/src/helpers/toPropertyKey.ts b/packages/babel-helpers/src/helpers/toPropertyKey.ts new file mode 100644 index 000000000000..d9c6a8ed8518 --- /dev/null +++ b/packages/babel-helpers/src/helpers/toPropertyKey.ts @@ -0,0 +1,11 @@ +/* @minVersion 7.1.5 */ + +// https://tc39.es/ecma262/#sec-topropertykey + +// @ts-expect-error helper +import toPrimitive from "toPrimitive"; + +export default function toPropertyKey(arg: unknown) { + var key = toPrimitive(arg, "string"); + return typeof key === "symbol" ? key : String(key); +} diff --git a/packages/babel-helpers/test/fixtures/misc/declaration-name-conflict-helper-entrypoint/output.js b/packages/babel-helpers/test/fixtures/misc/declaration-name-conflict-helper-entrypoint/output.js index 9ec9fcccfb48..6c1eca0ee975 100644 --- a/packages/babel-helpers/test/fixtures/misc/declaration-name-conflict-helper-entrypoint/output.js +++ b/packages/babel-helpers/test/fixtures/misc/declaration-name-conflict-helper-entrypoint/output.js @@ -1,8 +1,8 @@ function __set(target, property, value, receiver) { if (typeof Reflect !== "undefined" && Reflect.set) { __set = Reflect.set; } else { __set = function set(target, property, value, receiver) { var base = _superPropBase(target, property); var desc; if (base) { desc = Object.getOwnPropertyDescriptor(base, property); if (desc.set) { desc.set.call(receiver, value); return true; } else if (!desc.writable) { return false; } } desc = Object.getOwnPropertyDescriptor(receiver, property); if (desc) { if (!desc.writable) { return false; } desc.value = value; Object.defineProperty(receiver, property, desc); } else { _defineProperty(receiver, property, value); } return true; }; } return __set(target, property, value, receiver); } function _set(target, property, value, receiver, isStrict) { var s = __set(target, property, value, receiver || target); if (!s && isStrict) { throw new TypeError('failed to set property'); } return value; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); } +function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } // We'll add the helper `set`. It needs to be renamed to `_set` to avoid diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..c2a1429d240d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static accessor a; + @dec static accessor #a; + + @dec static accessor "b" + @dec static accessor ["c"]; + + @dec static accessor 0; + @dec static accessor [1]; + + @dec static accessor 2n; + @dec static accessor [3n]; + + @dec static accessor [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/context-name/input.js new file mode 100644 index 000000000000..c2a1429d240d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static accessor a; + @dec static accessor #a; + + @dec static accessor "b" + @dec static accessor ["c"]; + + @dec static accessor 0; + @dec static accessor [1]; + + @dec static accessor 2n; + @dec static accessor [3n]; + + @dec static accessor [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/context-name/output.js new file mode 100644 index 000000000000..e1c323a7c406 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/context-name/output.js @@ -0,0 +1,124 @@ +var _init_a, _init_a2, _get_a, _set_a, _init_computedKey, _computedKey, _init_computedKey2, _init_computedKey3, _computedKey2, _init_computedKey4, _init_computedKey5, _computedKey3, _init_computedKey6, _computedKey4, _init_computedKey7, _initStatic, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +var _a = /*#__PURE__*/new WeakMap(); +class Foo { + constructor() { + babelHelpers.classPrivateFieldInitSpec(this, _a, { + get: _get_a2, + set: _set_a2 + }); + } + static get a() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _A); + } + static set a(v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _A, v); + } + static get "b"() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _C); + } + static set "b"(v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _C, v); + } + static get [_computedKey]() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _D); + } + static set [_computedKey](v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _D, v); + } + static get 0() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _E); + } + static set 0(v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _E, v); + } + static get [_computedKey2]() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _F); + } + static set [_computedKey2](v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _F, v); + } + static get 2n() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _G); + } + static set 2n(v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _G, v); + } + static get [_computedKey3]() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _H); + } + static set [_computedKey3](v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _H, v); + } + static get [_computedKey4]() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _I); + } + static set [_computedKey4](v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _I, v); + } +} +_class = Foo; +function _set_a2(v) { + _set_a(this, v); +} +function _get_a2() { + return _get_a(this); +} +(() => { + [_init_a, _init_a2, _get_a, _set_a, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7, _initStatic] = babelHelpers.applyDecs(_class, [[dec, 6, "a"], [dec, 6, "a", function () { + return babelHelpers.classStaticPrivateFieldSpecGet(this, _class, _B); + }, function (value) { + babelHelpers.classStaticPrivateFieldSpecSet(this, _class, _B, value); + }], [dec, 6, "b"], [dec, 6, _computedKey], [dec, 6, 0], [dec, 6, _computedKey2], [dec, 6, 2n], [dec, 6, _computedKey3], [dec, 6, _computedKey4]], []); + _initStatic(_class); +})(); +var _A = { + writable: true, + value: _init_a(_class) +}; +var _B = { + writable: true, + value: _init_a2(_class) +}; +var _C = { + writable: true, + value: _init_computedKey(_class) +}; +var _D = { + writable: true, + value: _init_computedKey2(_class) +}; +var _E = { + writable: true, + value: _init_computedKey3(_class) +}; +var _F = { + writable: true, + value: _init_computedKey4(_class) +}; +var _G = { + writable: true, + value: _init_computedKey5(_class) +}; +var _H = { + writable: true, + value: _init_computedKey6(_class) +}; +var _I = { + writable: true, + value: _init_computedKey7(_class) +}; +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/context-name/exec.js new file mode 100644 index 000000000000..c2a1429d240d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static accessor a; + @dec static accessor #a; + + @dec static accessor "b" + @dec static accessor ["c"]; + + @dec static accessor 0; + @dec static accessor [1]; + + @dec static accessor 2n; + @dec static accessor [3n]; + + @dec static accessor [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/context-name/input.js new file mode 100644 index 000000000000..c2a1429d240d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static accessor a; + @dec static accessor #a; + + @dec static accessor "b" + @dec static accessor ["c"]; + + @dec static accessor 0; + @dec static accessor [1]; + + @dec static accessor 2n; + @dec static accessor [3n]; + + @dec static accessor [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/context-name/output.js new file mode 100644 index 000000000000..54433933303a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/context-name/output.js @@ -0,0 +1,89 @@ +var _init_a, _init_a2, _get_a, _set_a, _init_computedKey, _computedKey, _init_computedKey2, _init_computedKey3, _computedKey2, _init_computedKey4, _init_computedKey5, _computedKey3, _init_computedKey6, _computedKey4, _init_computedKey7, _initStatic; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_init_a, _init_a2, _get_a, _set_a, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7, _initStatic] = babelHelpers.applyDecs(this, [[dec, 6, "a"], [dec, 6, "a", function () { + return this.#B; + }, function (value) { + this.#B = value; + }], [dec, 6, "b"], [dec, 6, _computedKey], [dec, 6, 0], [dec, 6, _computedKey2], [dec, 6, 2n], [dec, 6, _computedKey3], [dec, 6, _computedKey4]], []); + _initStatic(this); + } + static #A = _init_a(this); + static get a() { + return this.#A; + } + static set a(v) { + this.#A = v; + } + static #B = _init_a2(this); + set #a(v) { + _set_a(this, v); + } + get #a() { + return _get_a(this); + } + static #C = _init_computedKey(this); + static get "b"() { + return this.#C; + } + static set "b"(v) { + this.#C = v; + } + static #D = _init_computedKey2(this); + static get [_computedKey]() { + return this.#D; + } + static set [_computedKey](v) { + this.#D = v; + } + static #E = _init_computedKey3(this); + static get 0() { + return this.#E; + } + static set 0(v) { + this.#E = v; + } + static #F = _init_computedKey4(this); + static get [_computedKey2]() { + return this.#F; + } + static set [_computedKey2](v) { + this.#F = v; + } + static #G = _init_computedKey5(this); + static get 2n() { + return this.#G; + } + static set 2n(v) { + this.#G = v; + } + static #H = _init_computedKey6(this); + static get [_computedKey3]() { + return this.#H; + } + static set [_computedKey3](v) { + this.#H = v; + } + static #I = _init_computedKey7(this); + static get [_computedKey4]() { + return this.#I; + } + static set [_computedKey4](v) { + this.#I = v; + } +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..45a0db870f28 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a; + @dec static #a; + + @dec static "b" + @dec static ["c"]; + + @dec static 0; + @dec static [1]; + + @dec static 2n; + @dec static [3n]; + + @dec static [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields--to-es2015/context-name/input.js new file mode 100644 index 000000000000..45a0db870f28 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a; + @dec static #a; + + @dec static "b" + @dec static ["c"]; + + @dec static 0; + @dec static [1]; + + @dec static 2n; + @dec static [3n]; + + @dec static [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields--to-es2015/context-name/output.js new file mode 100644 index 000000000000..1fa2e49f0292 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields--to-es2015/context-name/output.js @@ -0,0 +1,35 @@ +var _init_a, _init_a2, _init_computedKey, _computedKey, _init_computedKey2, _init_computedKey3, _computedKey2, _init_computedKey4, _init_computedKey5, _computedKey3, _init_computedKey6, _computedKey4, _init_computedKey7, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo {} +_class = Foo; +[_init_a, _init_a2, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7] = babelHelpers.applyDecs(_class, [[dec, 5, "a"], [dec, 5, "a", function () { + return babelHelpers.classStaticPrivateFieldSpecGet(this, _class, _a); +}, function (value) { + babelHelpers.classStaticPrivateFieldSpecSet(this, _class, _a, value); +}], [dec, 5, "b"], [dec, 5, _computedKey], [dec, 5, 0], [dec, 5, _computedKey2], [dec, 5, 2n], [dec, 5, _computedKey3], [dec, 5, _computedKey4]], []); +babelHelpers.defineProperty(Foo, "a", _init_a(_class)); +var _a = { + writable: true, + value: _init_a2(_class) +}; +babelHelpers.defineProperty(Foo, "b", _init_computedKey(_class)); +babelHelpers.defineProperty(Foo, _computedKey, _init_computedKey2(_class)); +babelHelpers.defineProperty(Foo, 0, _init_computedKey3(_class)); +babelHelpers.defineProperty(Foo, _computedKey2, _init_computedKey4(_class)); +babelHelpers.defineProperty(Foo, 2n, _init_computedKey5(_class)); +babelHelpers.defineProperty(Foo, _computedKey3, _init_computedKey6(_class)); +babelHelpers.defineProperty(Foo, _computedKey4, _init_computedKey7(_class)); +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields/context-name/exec.js new file mode 100644 index 000000000000..45a0db870f28 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a; + @dec static #a; + + @dec static "b" + @dec static ["c"]; + + @dec static 0; + @dec static [1]; + + @dec static 2n; + @dec static [3n]; + + @dec static [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields/context-name/input.js new file mode 100644 index 000000000000..45a0db870f28 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a; + @dec static #a; + + @dec static "b" + @dec static ["c"]; + + @dec static 0; + @dec static [1]; + + @dec static 2n; + @dec static [3n]; + + @dec static [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields/context-name/output.js new file mode 100644 index 000000000000..6ec02e38e95e --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-fields/context-name/output.js @@ -0,0 +1,34 @@ +var _init_a, _init_a2, _init_computedKey, _computedKey, _init_computedKey2, _init_computedKey3, _computedKey2, _init_computedKey4, _init_computedKey5, _computedKey3, _init_computedKey6, _computedKey4, _init_computedKey7; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_init_a, _init_a2, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7] = babelHelpers.applyDecs(this, [[dec, 5, "a"], [dec, 5, "a", function () { + return this.#a; + }, function (value) { + this.#a = value; + }], [dec, 5, "b"], [dec, 5, _computedKey], [dec, 5, 0], [dec, 5, _computedKey2], [dec, 5, 2n], [dec, 5, _computedKey3], [dec, 5, _computedKey4]], []); + } + static a = _init_a(this); + static #a = _init_a2(this); + static "b" = _init_computedKey(this); + static [_computedKey] = _init_computedKey2(this); + static 0 = _init_computedKey3(this); + static [_computedKey2] = _init_computedKey4(this); + static 2n = _init_computedKey5(this); + static [_computedKey3] = _init_computedKey6(this); + static [_computedKey4] = _init_computedKey7(this); +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..333a1d19d6a5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static get a() {}; + @dec static get #a() {}; + + @dec static get "b"() {} + @dec static get ["c"]() {}; + + @dec static get 0() {}; + @dec static get [1]() {}; + + @dec static get 2n() {}; + @dec static get [3n]() {}; + + @dec static get [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters--to-es2015/context-name/input.js new file mode 100644 index 000000000000..333a1d19d6a5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static get a() {}; + @dec static get #a() {}; + + @dec static get "b"() {} + @dec static get ["c"]() {}; + + @dec static get 0() {}; + @dec static get [1]() {}; + + @dec static get 2n() {}; + @dec static get [3n]() {}; + + @dec static get [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters--to-es2015/context-name/output.js new file mode 100644 index 000000000000..f89aad39f43a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters--to-es2015/context-name/output.js @@ -0,0 +1,38 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static get a() {} + static get "b"() {} + static get [_computedKey]() {} + static get 0() {} + static get [_computedKey2]() {} + static get 2n() {} + static get [_computedKey3]() {} + static get [_computedKey4]() {} +} +_class = Foo; +function _get_a() { + return _call_a(this); +} +var _a = { + get: _get_a, + set: void 0 +}; +(() => { + [_call_a, _initStatic] = babelHelpers.applyDecs(_class, [[dec, 8, "a"], [dec, 8, "a", function () {}], [dec, 8, "b"], [dec, 8, _computedKey], [dec, 8, 0], [dec, 8, _computedKey2], [dec, 8, 2n], [dec, 8, _computedKey3], [dec, 8, _computedKey4]], []); + _initStatic(_class); +})(); +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters/context-name/exec.js new file mode 100644 index 000000000000..333a1d19d6a5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static get a() {}; + @dec static get #a() {}; + + @dec static get "b"() {} + @dec static get ["c"]() {}; + + @dec static get 0() {}; + @dec static get [1]() {}; + + @dec static get 2n() {}; + @dec static get [3n]() {}; + + @dec static get [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters/context-name/input.js new file mode 100644 index 000000000000..333a1d19d6a5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static get a() {}; + @dec static get #a() {}; + + @dec static get "b"() {} + @dec static get ["c"]() {}; + + @dec static get 0() {}; + @dec static get [1]() {}; + + @dec static get 2n() {}; + @dec static get [3n]() {}; + + @dec static get [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters/context-name/output.js new file mode 100644 index 000000000000..99caa15cee91 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-getters/context-name/output.js @@ -0,0 +1,33 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_call_a, _initStatic] = babelHelpers.applyDecs(this, [[dec, 8, "a"], [dec, 8, "a", function () {}], [dec, 8, "b"], [dec, 8, _computedKey], [dec, 8, 0], [dec, 8, _computedKey2], [dec, 8, 2n], [dec, 8, _computedKey3], [dec, 8, _computedKey4]], []); + _initStatic(this); + } + static get a() {} + static get #a() { + return _call_a(this); + } + static get "b"() {} + static get [_computedKey]() {} + static get 0() {} + static get [_computedKey2]() {} + static get 2n() {} + static get [_computedKey3]() {} + static get [_computedKey4]() {} +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..f22ec7c2e74a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a() {}; + @dec static #a() {}; + + @dec static "b"() {} + @dec static ["c"]() {}; + + @dec static 0() {}; + @dec static [1]() {}; + + @dec static 2n() {}; + @dec static [3n]() {}; + + @dec static [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods--to-es2015/context-name/input.js new file mode 100644 index 000000000000..f22ec7c2e74a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a() {}; + @dec static #a() {}; + + @dec static "b"() {} + @dec static ["c"]() {}; + + @dec static 0() {}; + @dec static [1]() {}; + + @dec static 2n() {}; + @dec static [3n]() {}; + + @dec static [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods--to-es2015/context-name/output.js new file mode 100644 index 000000000000..9e34f45a788c --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods--to-es2015/context-name/output.js @@ -0,0 +1,35 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static a() {} + static "b"() {} + static [_computedKey]() {} + static 0() {} + static [_computedKey2]() {} + static 2n() {} + static [_computedKey3]() {} + static [_computedKey4]() {} +} +_class = Foo; +(() => { + [_call_a, _initStatic] = babelHelpers.applyDecs(_class, [[dec, 7, "a"], [dec, 7, "a", function () {}], [dec, 7, "b"], [dec, 7, _computedKey], [dec, 7, 0], [dec, 7, _computedKey2], [dec, 7, 2n], [dec, 7, _computedKey3], [dec, 7, _computedKey4]], []); + _initStatic(_class); +})(); +var _a = { + writable: true, + value: _call_a +}; +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods/context-name/exec.js new file mode 100644 index 000000000000..f22ec7c2e74a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a() {}; + @dec static #a() {}; + + @dec static "b"() {} + @dec static ["c"]() {}; + + @dec static 0() {}; + @dec static [1]() {}; + + @dec static 2n() {}; + @dec static [3n]() {}; + + @dec static [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods/context-name/input.js new file mode 100644 index 000000000000..f22ec7c2e74a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a() {}; + @dec static #a() {}; + + @dec static "b"() {} + @dec static ["c"]() {}; + + @dec static 0() {}; + @dec static [1]() {}; + + @dec static 2n() {}; + @dec static [3n]() {}; + + @dec static [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods/context-name/output.js new file mode 100644 index 000000000000..35e53a57be0a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-methods/context-name/output.js @@ -0,0 +1,31 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_call_a, _initStatic] = babelHelpers.applyDecs(this, [[dec, 7, "a"], [dec, 7, "a", function () {}], [dec, 7, "b"], [dec, 7, _computedKey], [dec, 7, 0], [dec, 7, _computedKey2], [dec, 7, 2n], [dec, 7, _computedKey3], [dec, 7, _computedKey4]], []); + _initStatic(this); + } + static #a = _call_a; + static a() {} + static "b"() {} + static [_computedKey]() {} + static 0() {} + static [_computedKey2]() {} + static 2n() {} + static [_computedKey3]() {} + static [_computedKey4]() {} +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..5f2fc10d4634 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static set a(v) {}; + @dec static set #a(v) {}; + + @dec static set "b"(v) {} + @dec static set ["c"](v) {}; + + @dec static set 0(v) {}; + @dec static set [1](v) {}; + + @dec static set 2n(v) {}; + @dec static set [3n](v) {}; + + @dec static set [f()](v) {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters--to-es2015/context-name/input.js new file mode 100644 index 000000000000..5f2fc10d4634 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static set a(v) {}; + @dec static set #a(v) {}; + + @dec static set "b"(v) {} + @dec static set ["c"](v) {}; + + @dec static set 0(v) {}; + @dec static set [1](v) {}; + + @dec static set 2n(v) {}; + @dec static set [3n](v) {}; + + @dec static set [f()](v) {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters--to-es2015/context-name/output.js new file mode 100644 index 000000000000..de868cb16483 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters--to-es2015/context-name/output.js @@ -0,0 +1,38 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static set a(v) {} + static set "b"(v) {} + static set [_computedKey](v) {} + static set 0(v) {} + static set [_computedKey2](v) {} + static set 2n(v) {} + static set [_computedKey3](v) {} + static set [_computedKey4](v) {} +} +_class = Foo; +function _set_a(v) { + _call_a(this, v); +} +var _a = { + get: void 0, + set: _set_a +}; +(() => { + [_call_a, _initStatic] = babelHelpers.applyDecs(_class, [[dec, 9, "a"], [dec, 9, "a", function (v) {}], [dec, 9, "b"], [dec, 9, _computedKey], [dec, 9, 0], [dec, 9, _computedKey2], [dec, 9, 2n], [dec, 9, _computedKey3], [dec, 9, _computedKey4]], []); + _initStatic(_class); +})(); +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters/context-name/exec.js new file mode 100644 index 000000000000..5f2fc10d4634 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static set a(v) {}; + @dec static set #a(v) {}; + + @dec static set "b"(v) {} + @dec static set ["c"](v) {}; + + @dec static set 0(v) {}; + @dec static set [1](v) {}; + + @dec static set 2n(v) {}; + @dec static set [3n](v) {}; + + @dec static set [f()](v) {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters/context-name/input.js new file mode 100644 index 000000000000..5f2fc10d4634 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static set a(v) {}; + @dec static set #a(v) {}; + + @dec static set "b"(v) {} + @dec static set ["c"](v) {}; + + @dec static set 0(v) {}; + @dec static set [1](v) {}; + + @dec static set 2n(v) {}; + @dec static set [3n](v) {}; + + @dec static set [f()](v) {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters/context-name/output.js new file mode 100644 index 000000000000..1217a8ffe176 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-setters/context-name/output.js @@ -0,0 +1,33 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_call_a, _initStatic] = babelHelpers.applyDecs(this, [[dec, 9, "a"], [dec, 9, "a", function (v) {}], [dec, 9, "b"], [dec, 9, _computedKey], [dec, 9, 0], [dec, 9, _computedKey2], [dec, 9, 2n], [dec, 9, _computedKey3], [dec, 9, _computedKey4]], []); + _initStatic(this); + } + static set a(v) {} + static set #a(v) { + _call_a(this, v); + } + static set "b"(v) {} + static set [_computedKey](v) {} + static set 0(v) {} + static set [_computedKey2](v) {} + static set 2n(v) {} + static set [_computedKey3](v) {} + static set [_computedKey4](v) {} +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..c2a1429d240d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static accessor a; + @dec static accessor #a; + + @dec static accessor "b" + @dec static accessor ["c"]; + + @dec static accessor 0; + @dec static accessor [1]; + + @dec static accessor 2n; + @dec static accessor [3n]; + + @dec static accessor [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/context-name/input.js new file mode 100644 index 000000000000..c2a1429d240d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static accessor a; + @dec static accessor #a; + + @dec static accessor "b" + @dec static accessor ["c"]; + + @dec static accessor 0; + @dec static accessor [1]; + + @dec static accessor 2n; + @dec static accessor [3n]; + + @dec static accessor [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/context-name/output.js new file mode 100644 index 000000000000..09f31070035b --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/context-name/output.js @@ -0,0 +1,124 @@ +var _init_a, _init_a2, _get_a, _set_a, _init_computedKey, _computedKey, _init_computedKey2, _init_computedKey3, _computedKey2, _init_computedKey4, _init_computedKey5, _computedKey3, _init_computedKey6, _computedKey4, _init_computedKey7, _initStatic, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +var _a = /*#__PURE__*/new WeakMap(); +class Foo { + constructor() { + babelHelpers.classPrivateFieldInitSpec(this, _a, { + get: _get_a2, + set: _set_a2 + }); + } + static get a() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _A); + } + static set a(v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _A, v); + } + static get "b"() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _C); + } + static set "b"(v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _C, v); + } + static get [_computedKey]() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _D); + } + static set [_computedKey](v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _D, v); + } + static get 0() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _E); + } + static set 0(v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _E, v); + } + static get [_computedKey2]() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _F); + } + static set [_computedKey2](v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _F, v); + } + static get 2n() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _G); + } + static set 2n(v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _G, v); + } + static get [_computedKey3]() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _H); + } + static set [_computedKey3](v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _H, v); + } + static get [_computedKey4]() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _I); + } + static set [_computedKey4](v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _I, v); + } +} +_class = Foo; +function _set_a2(v) { + _set_a(this, v); +} +function _get_a2() { + return _get_a(this); +} +(() => { + [_init_a, _init_a2, _get_a, _set_a, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7, _initStatic] = babelHelpers.applyDecs2203R(_class, [[dec, 6, "a"], [dec, 6, "a", function () { + return babelHelpers.classStaticPrivateFieldSpecGet(this, _class, _B); + }, function (value) { + babelHelpers.classStaticPrivateFieldSpecSet(this, _class, _B, value); + }], [dec, 6, "b"], [dec, 6, _computedKey], [dec, 6, 0], [dec, 6, _computedKey2], [dec, 6, 2n], [dec, 6, _computedKey3], [dec, 6, _computedKey4]], []).e; + _initStatic(_class); +})(); +var _A = { + writable: true, + value: _init_a(_class) +}; +var _B = { + writable: true, + value: _init_a2(_class) +}; +var _C = { + writable: true, + value: _init_computedKey(_class) +}; +var _D = { + writable: true, + value: _init_computedKey2(_class) +}; +var _E = { + writable: true, + value: _init_computedKey3(_class) +}; +var _F = { + writable: true, + value: _init_computedKey4(_class) +}; +var _G = { + writable: true, + value: _init_computedKey5(_class) +}; +var _H = { + writable: true, + value: _init_computedKey6(_class) +}; +var _I = { + writable: true, + value: _init_computedKey7(_class) +}; +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/context-name/exec.js new file mode 100644 index 000000000000..c2a1429d240d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static accessor a; + @dec static accessor #a; + + @dec static accessor "b" + @dec static accessor ["c"]; + + @dec static accessor 0; + @dec static accessor [1]; + + @dec static accessor 2n; + @dec static accessor [3n]; + + @dec static accessor [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/context-name/input.js new file mode 100644 index 000000000000..c2a1429d240d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static accessor a; + @dec static accessor #a; + + @dec static accessor "b" + @dec static accessor ["c"]; + + @dec static accessor 0; + @dec static accessor [1]; + + @dec static accessor 2n; + @dec static accessor [3n]; + + @dec static accessor [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/context-name/output.js new file mode 100644 index 000000000000..474ecf811122 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/context-name/output.js @@ -0,0 +1,89 @@ +var _init_a, _init_a2, _get_a, _set_a, _init_computedKey, _computedKey, _init_computedKey2, _init_computedKey3, _computedKey2, _init_computedKey4, _init_computedKey5, _computedKey3, _init_computedKey6, _computedKey4, _init_computedKey7, _initStatic; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_init_a, _init_a2, _get_a, _set_a, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7, _initStatic] = babelHelpers.applyDecs2203R(this, [[dec, 6, "a"], [dec, 6, "a", function () { + return this.#B; + }, function (value) { + this.#B = value; + }], [dec, 6, "b"], [dec, 6, _computedKey], [dec, 6, 0], [dec, 6, _computedKey2], [dec, 6, 2n], [dec, 6, _computedKey3], [dec, 6, _computedKey4]], []).e; + _initStatic(this); + } + static #A = _init_a(this); + static get a() { + return this.#A; + } + static set a(v) { + this.#A = v; + } + static #B = _init_a2(this); + set #a(v) { + _set_a(this, v); + } + get #a() { + return _get_a(this); + } + static #C = _init_computedKey(this); + static get "b"() { + return this.#C; + } + static set "b"(v) { + this.#C = v; + } + static #D = _init_computedKey2(this); + static get [_computedKey]() { + return this.#D; + } + static set [_computedKey](v) { + this.#D = v; + } + static #E = _init_computedKey3(this); + static get 0() { + return this.#E; + } + static set 0(v) { + this.#E = v; + } + static #F = _init_computedKey4(this); + static get [_computedKey2]() { + return this.#F; + } + static set [_computedKey2](v) { + this.#F = v; + } + static #G = _init_computedKey5(this); + static get 2n() { + return this.#G; + } + static set 2n(v) { + this.#G = v; + } + static #H = _init_computedKey6(this); + static get [_computedKey3]() { + return this.#H; + } + static set [_computedKey3](v) { + this.#H = v; + } + static #I = _init_computedKey7(this); + static get [_computedKey4]() { + return this.#I; + } + static set [_computedKey4](v) { + this.#I = v; + } +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..45a0db870f28 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a; + @dec static #a; + + @dec static "b" + @dec static ["c"]; + + @dec static 0; + @dec static [1]; + + @dec static 2n; + @dec static [3n]; + + @dec static [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields--to-es2015/context-name/input.js new file mode 100644 index 000000000000..45a0db870f28 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a; + @dec static #a; + + @dec static "b" + @dec static ["c"]; + + @dec static 0; + @dec static [1]; + + @dec static 2n; + @dec static [3n]; + + @dec static [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields--to-es2015/context-name/output.js new file mode 100644 index 000000000000..aa8053ba7c80 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields--to-es2015/context-name/output.js @@ -0,0 +1,35 @@ +var _init_a, _init_a2, _init_computedKey, _computedKey, _init_computedKey2, _init_computedKey3, _computedKey2, _init_computedKey4, _init_computedKey5, _computedKey3, _init_computedKey6, _computedKey4, _init_computedKey7, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo {} +_class = Foo; +[_init_a, _init_a2, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7] = babelHelpers.applyDecs2203R(_class, [[dec, 5, "a"], [dec, 5, "a", function () { + return babelHelpers.classStaticPrivateFieldSpecGet(this, _class, _a); +}, function (value) { + babelHelpers.classStaticPrivateFieldSpecSet(this, _class, _a, value); +}], [dec, 5, "b"], [dec, 5, _computedKey], [dec, 5, 0], [dec, 5, _computedKey2], [dec, 5, 2n], [dec, 5, _computedKey3], [dec, 5, _computedKey4]], []).e; +babelHelpers.defineProperty(Foo, "a", _init_a(_class)); +var _a = { + writable: true, + value: _init_a2(_class) +}; +babelHelpers.defineProperty(Foo, "b", _init_computedKey(_class)); +babelHelpers.defineProperty(Foo, _computedKey, _init_computedKey2(_class)); +babelHelpers.defineProperty(Foo, 0, _init_computedKey3(_class)); +babelHelpers.defineProperty(Foo, _computedKey2, _init_computedKey4(_class)); +babelHelpers.defineProperty(Foo, 2n, _init_computedKey5(_class)); +babelHelpers.defineProperty(Foo, _computedKey3, _init_computedKey6(_class)); +babelHelpers.defineProperty(Foo, _computedKey4, _init_computedKey7(_class)); +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields/context-name/exec.js new file mode 100644 index 000000000000..45a0db870f28 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a; + @dec static #a; + + @dec static "b" + @dec static ["c"]; + + @dec static 0; + @dec static [1]; + + @dec static 2n; + @dec static [3n]; + + @dec static [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields/context-name/input.js new file mode 100644 index 000000000000..45a0db870f28 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a; + @dec static #a; + + @dec static "b" + @dec static ["c"]; + + @dec static 0; + @dec static [1]; + + @dec static 2n; + @dec static [3n]; + + @dec static [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields/context-name/output.js new file mode 100644 index 000000000000..e5a3cc7be4a4 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-fields/context-name/output.js @@ -0,0 +1,34 @@ +var _init_a, _init_a2, _init_computedKey, _computedKey, _init_computedKey2, _init_computedKey3, _computedKey2, _init_computedKey4, _init_computedKey5, _computedKey3, _init_computedKey6, _computedKey4, _init_computedKey7; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_init_a, _init_a2, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7] = babelHelpers.applyDecs2203R(this, [[dec, 5, "a"], [dec, 5, "a", function () { + return this.#a; + }, function (value) { + this.#a = value; + }], [dec, 5, "b"], [dec, 5, _computedKey], [dec, 5, 0], [dec, 5, _computedKey2], [dec, 5, 2n], [dec, 5, _computedKey3], [dec, 5, _computedKey4]], []).e; + } + static a = _init_a(this); + static #a = _init_a2(this); + static "b" = _init_computedKey(this); + static [_computedKey] = _init_computedKey2(this); + static 0 = _init_computedKey3(this); + static [_computedKey2] = _init_computedKey4(this); + static 2n = _init_computedKey5(this); + static [_computedKey3] = _init_computedKey6(this); + static [_computedKey4] = _init_computedKey7(this); +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..333a1d19d6a5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static get a() {}; + @dec static get #a() {}; + + @dec static get "b"() {} + @dec static get ["c"]() {}; + + @dec static get 0() {}; + @dec static get [1]() {}; + + @dec static get 2n() {}; + @dec static get [3n]() {}; + + @dec static get [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters--to-es2015/context-name/input.js new file mode 100644 index 000000000000..333a1d19d6a5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static get a() {}; + @dec static get #a() {}; + + @dec static get "b"() {} + @dec static get ["c"]() {}; + + @dec static get 0() {}; + @dec static get [1]() {}; + + @dec static get 2n() {}; + @dec static get [3n]() {}; + + @dec static get [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters--to-es2015/context-name/output.js new file mode 100644 index 000000000000..d04a3ef9ef10 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters--to-es2015/context-name/output.js @@ -0,0 +1,38 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static get a() {} + static get "b"() {} + static get [_computedKey]() {} + static get 0() {} + static get [_computedKey2]() {} + static get 2n() {} + static get [_computedKey3]() {} + static get [_computedKey4]() {} +} +_class = Foo; +function _get_a() { + return _call_a(this); +} +var _a = { + get: _get_a, + set: void 0 +}; +(() => { + [_call_a, _initStatic] = babelHelpers.applyDecs2203R(_class, [[dec, 8, "a"], [dec, 8, "a", function () {}], [dec, 8, "b"], [dec, 8, _computedKey], [dec, 8, 0], [dec, 8, _computedKey2], [dec, 8, 2n], [dec, 8, _computedKey3], [dec, 8, _computedKey4]], []).e; + _initStatic(_class); +})(); +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters/context-name/exec.js new file mode 100644 index 000000000000..333a1d19d6a5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static get a() {}; + @dec static get #a() {}; + + @dec static get "b"() {} + @dec static get ["c"]() {}; + + @dec static get 0() {}; + @dec static get [1]() {}; + + @dec static get 2n() {}; + @dec static get [3n]() {}; + + @dec static get [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters/context-name/input.js new file mode 100644 index 000000000000..333a1d19d6a5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static get a() {}; + @dec static get #a() {}; + + @dec static get "b"() {} + @dec static get ["c"]() {}; + + @dec static get 0() {}; + @dec static get [1]() {}; + + @dec static get 2n() {}; + @dec static get [3n]() {}; + + @dec static get [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters/context-name/output.js new file mode 100644 index 000000000000..767fcee9fdcd --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-getters/context-name/output.js @@ -0,0 +1,33 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_call_a, _initStatic] = babelHelpers.applyDecs2203R(this, [[dec, 8, "a"], [dec, 8, "a", function () {}], [dec, 8, "b"], [dec, 8, _computedKey], [dec, 8, 0], [dec, 8, _computedKey2], [dec, 8, 2n], [dec, 8, _computedKey3], [dec, 8, _computedKey4]], []).e; + _initStatic(this); + } + static get a() {} + static get #a() { + return _call_a(this); + } + static get "b"() {} + static get [_computedKey]() {} + static get 0() {} + static get [_computedKey2]() {} + static get 2n() {} + static get [_computedKey3]() {} + static get [_computedKey4]() {} +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..f22ec7c2e74a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a() {}; + @dec static #a() {}; + + @dec static "b"() {} + @dec static ["c"]() {}; + + @dec static 0() {}; + @dec static [1]() {}; + + @dec static 2n() {}; + @dec static [3n]() {}; + + @dec static [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods--to-es2015/context-name/input.js new file mode 100644 index 000000000000..f22ec7c2e74a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a() {}; + @dec static #a() {}; + + @dec static "b"() {} + @dec static ["c"]() {}; + + @dec static 0() {}; + @dec static [1]() {}; + + @dec static 2n() {}; + @dec static [3n]() {}; + + @dec static [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods--to-es2015/context-name/output.js new file mode 100644 index 000000000000..7afdbaa0593a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods--to-es2015/context-name/output.js @@ -0,0 +1,35 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static a() {} + static "b"() {} + static [_computedKey]() {} + static 0() {} + static [_computedKey2]() {} + static 2n() {} + static [_computedKey3]() {} + static [_computedKey4]() {} +} +_class = Foo; +(() => { + [_call_a, _initStatic] = babelHelpers.applyDecs2203R(_class, [[dec, 7, "a"], [dec, 7, "a", function () {}], [dec, 7, "b"], [dec, 7, _computedKey], [dec, 7, 0], [dec, 7, _computedKey2], [dec, 7, 2n], [dec, 7, _computedKey3], [dec, 7, _computedKey4]], []).e; + _initStatic(_class); +})(); +var _a = { + writable: true, + value: _call_a +}; +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods/context-name/exec.js new file mode 100644 index 000000000000..f22ec7c2e74a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a() {}; + @dec static #a() {}; + + @dec static "b"() {} + @dec static ["c"]() {}; + + @dec static 0() {}; + @dec static [1]() {}; + + @dec static 2n() {}; + @dec static [3n]() {}; + + @dec static [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods/context-name/input.js new file mode 100644 index 000000000000..f22ec7c2e74a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a() {}; + @dec static #a() {}; + + @dec static "b"() {} + @dec static ["c"]() {}; + + @dec static 0() {}; + @dec static [1]() {}; + + @dec static 2n() {}; + @dec static [3n]() {}; + + @dec static [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods/context-name/output.js new file mode 100644 index 000000000000..e6cc62a45a87 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-methods/context-name/output.js @@ -0,0 +1,31 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_call_a, _initStatic] = babelHelpers.applyDecs2203R(this, [[dec, 7, "a"], [dec, 7, "a", function () {}], [dec, 7, "b"], [dec, 7, _computedKey], [dec, 7, 0], [dec, 7, _computedKey2], [dec, 7, 2n], [dec, 7, _computedKey3], [dec, 7, _computedKey4]], []).e; + _initStatic(this); + } + static #a = _call_a; + static a() {} + static "b"() {} + static [_computedKey]() {} + static 0() {} + static [_computedKey2]() {} + static 2n() {} + static [_computedKey3]() {} + static [_computedKey4]() {} +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..5f2fc10d4634 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static set a(v) {}; + @dec static set #a(v) {}; + + @dec static set "b"(v) {} + @dec static set ["c"](v) {}; + + @dec static set 0(v) {}; + @dec static set [1](v) {}; + + @dec static set 2n(v) {}; + @dec static set [3n](v) {}; + + @dec static set [f()](v) {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters--to-es2015/context-name/input.js new file mode 100644 index 000000000000..5f2fc10d4634 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static set a(v) {}; + @dec static set #a(v) {}; + + @dec static set "b"(v) {} + @dec static set ["c"](v) {}; + + @dec static set 0(v) {}; + @dec static set [1](v) {}; + + @dec static set 2n(v) {}; + @dec static set [3n](v) {}; + + @dec static set [f()](v) {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters--to-es2015/context-name/output.js new file mode 100644 index 000000000000..2488b6a6eaf6 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters--to-es2015/context-name/output.js @@ -0,0 +1,38 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static set a(v) {} + static set "b"(v) {} + static set [_computedKey](v) {} + static set 0(v) {} + static set [_computedKey2](v) {} + static set 2n(v) {} + static set [_computedKey3](v) {} + static set [_computedKey4](v) {} +} +_class = Foo; +function _set_a(v) { + _call_a(this, v); +} +var _a = { + get: void 0, + set: _set_a +}; +(() => { + [_call_a, _initStatic] = babelHelpers.applyDecs2203R(_class, [[dec, 9, "a"], [dec, 9, "a", function (v) {}], [dec, 9, "b"], [dec, 9, _computedKey], [dec, 9, 0], [dec, 9, _computedKey2], [dec, 9, 2n], [dec, 9, _computedKey3], [dec, 9, _computedKey4]], []).e; + _initStatic(_class); +})(); +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters/context-name/exec.js new file mode 100644 index 000000000000..5f2fc10d4634 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static set a(v) {}; + @dec static set #a(v) {}; + + @dec static set "b"(v) {} + @dec static set ["c"](v) {}; + + @dec static set 0(v) {}; + @dec static set [1](v) {}; + + @dec static set 2n(v) {}; + @dec static set [3n](v) {}; + + @dec static set [f()](v) {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters/context-name/input.js new file mode 100644 index 000000000000..5f2fc10d4634 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static set a(v) {}; + @dec static set #a(v) {}; + + @dec static set "b"(v) {} + @dec static set ["c"](v) {}; + + @dec static set 0(v) {}; + @dec static set [1](v) {}; + + @dec static set 2n(v) {}; + @dec static set [3n](v) {}; + + @dec static set [f()](v) {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters/context-name/output.js new file mode 100644 index 000000000000..2c2075c03f43 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-setters/context-name/output.js @@ -0,0 +1,33 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_call_a, _initStatic] = babelHelpers.applyDecs2203R(this, [[dec, 9, "a"], [dec, 9, "a", function (v) {}], [dec, 9, "b"], [dec, 9, _computedKey], [dec, 9, 0], [dec, 9, _computedKey2], [dec, 9, 2n], [dec, 9, _computedKey3], [dec, 9, _computedKey4]], []).e; + _initStatic(this); + } + static set a(v) {} + static set #a(v) { + _call_a(this, v); + } + static set "b"(v) {} + static set [_computedKey](v) {} + static set 0(v) {} + static set [_computedKey2](v) {} + static set 2n(v) {} + static set [_computedKey3](v) {} + static set [_computedKey4](v) {} +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..c2a1429d240d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static accessor a; + @dec static accessor #a; + + @dec static accessor "b" + @dec static accessor ["c"]; + + @dec static accessor 0; + @dec static accessor [1]; + + @dec static accessor 2n; + @dec static accessor [3n]; + + @dec static accessor [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/context-name/input.js new file mode 100644 index 000000000000..c2a1429d240d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static accessor a; + @dec static accessor #a; + + @dec static accessor "b" + @dec static accessor ["c"]; + + @dec static accessor 0; + @dec static accessor [1]; + + @dec static accessor 2n; + @dec static accessor [3n]; + + @dec static accessor [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/context-name/output.js new file mode 100644 index 000000000000..d19b69002480 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/context-name/output.js @@ -0,0 +1,120 @@ +var _init_a, _init_a2, _get_a, _set_a, _init_computedKey, _computedKey, _init_computedKey2, _init_computedKey3, _computedKey2, _init_computedKey4, _init_computedKey5, _computedKey3, _init_computedKey6, _computedKey4, _init_computedKey7, _initStatic, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +var _a = /*#__PURE__*/new WeakMap(); +class Foo { + constructor() { + babelHelpers.classPrivateFieldInitSpec(this, _a, { + get: _get_a2, + set: _set_a2 + }); + } + static get a() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _A); + } + static set a(v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _A, v); + } + static get "b"() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _C); + } + static set "b"(v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _C, v); + } + static get [_computedKey]() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _D); + } + static set [_computedKey](v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _D, v); + } + static get 0() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _E); + } + static set 0(v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _E, v); + } + static get [_computedKey2]() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _F); + } + static set [_computedKey2](v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _F, v); + } + static get 2n() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _G); + } + static set 2n(v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _G, v); + } + static get [_computedKey3]() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _H); + } + static set [_computedKey3](v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _H, v); + } + static get [_computedKey4]() { + return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _I); + } + static set [_computedKey4](v) { + babelHelpers.classStaticPrivateFieldSpecSet(this, Foo, _I, v); + } +} +_class = Foo; +function _set_a2(v) { + _set_a(this, v); +} +function _get_a2() { + return _get_a(this); +} +(() => { + [_init_a, _init_a2, _get_a, _set_a, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7, _initStatic] = babelHelpers.applyDecs2301(_class, [[dec, 6, "a"], [dec, 6, "a", o => babelHelpers.classStaticPrivateFieldSpecGet(o, _class, _B), (o, v) => babelHelpers.classStaticPrivateFieldSpecSet(o, _class, _B, v)], [dec, 6, "b"], [dec, 6, _computedKey], [dec, 6, 0], [dec, 6, _computedKey2], [dec, 6, 2n], [dec, 6, _computedKey3], [dec, 6, _computedKey4]], []).e; + _initStatic(_class); +})(); +var _A = { + writable: true, + value: _init_a(_class) +}; +var _B = { + writable: true, + value: _init_a2(_class) +}; +var _C = { + writable: true, + value: _init_computedKey(_class) +}; +var _D = { + writable: true, + value: _init_computedKey2(_class) +}; +var _E = { + writable: true, + value: _init_computedKey3(_class) +}; +var _F = { + writable: true, + value: _init_computedKey4(_class) +}; +var _G = { + writable: true, + value: _init_computedKey5(_class) +}; +var _H = { + writable: true, + value: _init_computedKey6(_class) +}; +var _I = { + writable: true, + value: _init_computedKey7(_class) +}; +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/context-name/exec.js new file mode 100644 index 000000000000..c2a1429d240d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static accessor a; + @dec static accessor #a; + + @dec static accessor "b" + @dec static accessor ["c"]; + + @dec static accessor 0; + @dec static accessor [1]; + + @dec static accessor 2n; + @dec static accessor [3n]; + + @dec static accessor [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/context-name/input.js new file mode 100644 index 000000000000..c2a1429d240d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static accessor a; + @dec static accessor #a; + + @dec static accessor "b" + @dec static accessor ["c"]; + + @dec static accessor 0; + @dec static accessor [1]; + + @dec static accessor 2n; + @dec static accessor [3n]; + + @dec static accessor [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/context-name/output.js new file mode 100644 index 000000000000..7a7a2412b7ed --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/context-name/output.js @@ -0,0 +1,85 @@ +var _init_a, _init_a2, _get_a, _set_a, _init_computedKey, _computedKey, _init_computedKey2, _init_computedKey3, _computedKey2, _init_computedKey4, _init_computedKey5, _computedKey3, _init_computedKey6, _computedKey4, _init_computedKey7, _initStatic; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_init_a, _init_a2, _get_a, _set_a, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7, _initStatic] = babelHelpers.applyDecs2301(this, [[dec, 6, "a"], [dec, 6, "a", o => o.#B, (o, v) => o.#B = v], [dec, 6, "b"], [dec, 6, _computedKey], [dec, 6, 0], [dec, 6, _computedKey2], [dec, 6, 2n], [dec, 6, _computedKey3], [dec, 6, _computedKey4]], []).e; + _initStatic(this); + } + static #A = _init_a(this); + static get a() { + return this.#A; + } + static set a(v) { + this.#A = v; + } + static #B = _init_a2(this); + set #a(v) { + _set_a(this, v); + } + get #a() { + return _get_a(this); + } + static #C = _init_computedKey(this); + static get "b"() { + return this.#C; + } + static set "b"(v) { + this.#C = v; + } + static #D = _init_computedKey2(this); + static get [_computedKey]() { + return this.#D; + } + static set [_computedKey](v) { + this.#D = v; + } + static #E = _init_computedKey3(this); + static get 0() { + return this.#E; + } + static set 0(v) { + this.#E = v; + } + static #F = _init_computedKey4(this); + static get [_computedKey2]() { + return this.#F; + } + static set [_computedKey2](v) { + this.#F = v; + } + static #G = _init_computedKey5(this); + static get 2n() { + return this.#G; + } + static set 2n(v) { + this.#G = v; + } + static #H = _init_computedKey6(this); + static get [_computedKey3]() { + return this.#H; + } + static set [_computedKey3](v) { + this.#H = v; + } + static #I = _init_computedKey7(this); + static get [_computedKey4]() { + return this.#I; + } + static set [_computedKey4](v) { + this.#I = v; + } +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..45a0db870f28 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a; + @dec static #a; + + @dec static "b" + @dec static ["c"]; + + @dec static 0; + @dec static [1]; + + @dec static 2n; + @dec static [3n]; + + @dec static [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/context-name/input.js new file mode 100644 index 000000000000..45a0db870f28 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a; + @dec static #a; + + @dec static "b" + @dec static ["c"]; + + @dec static 0; + @dec static [1]; + + @dec static 2n; + @dec static [3n]; + + @dec static [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/context-name/output.js new file mode 100644 index 000000000000..5de224ee5357 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields--to-es2015/context-name/output.js @@ -0,0 +1,31 @@ +var _init_a, _init_a2, _init_computedKey, _computedKey, _init_computedKey2, _init_computedKey3, _computedKey2, _init_computedKey4, _init_computedKey5, _computedKey3, _init_computedKey6, _computedKey4, _init_computedKey7, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo {} +_class = Foo; +[_init_a, _init_a2, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7] = babelHelpers.applyDecs2301(_class, [[dec, 5, "a"], [dec, 5, "a", o => babelHelpers.classStaticPrivateFieldSpecGet(o, _class, _a), (o, v) => babelHelpers.classStaticPrivateFieldSpecSet(o, _class, _a, v)], [dec, 5, "b"], [dec, 5, _computedKey], [dec, 5, 0], [dec, 5, _computedKey2], [dec, 5, 2n], [dec, 5, _computedKey3], [dec, 5, _computedKey4]], []).e; +babelHelpers.defineProperty(Foo, "a", _init_a(_class)); +var _a = { + writable: true, + value: _init_a2(_class) +}; +babelHelpers.defineProperty(Foo, "b", _init_computedKey(_class)); +babelHelpers.defineProperty(Foo, _computedKey, _init_computedKey2(_class)); +babelHelpers.defineProperty(Foo, 0, _init_computedKey3(_class)); +babelHelpers.defineProperty(Foo, _computedKey2, _init_computedKey4(_class)); +babelHelpers.defineProperty(Foo, 2n, _init_computedKey5(_class)); +babelHelpers.defineProperty(Foo, _computedKey3, _init_computedKey6(_class)); +babelHelpers.defineProperty(Foo, _computedKey4, _init_computedKey7(_class)); +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/context-name/exec.js new file mode 100644 index 000000000000..45a0db870f28 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a; + @dec static #a; + + @dec static "b" + @dec static ["c"]; + + @dec static 0; + @dec static [1]; + + @dec static 2n; + @dec static [3n]; + + @dec static [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/context-name/input.js new file mode 100644 index 000000000000..45a0db870f28 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a; + @dec static #a; + + @dec static "b" + @dec static ["c"]; + + @dec static 0; + @dec static [1]; + + @dec static 2n; + @dec static [3n]; + + @dec static [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/context-name/output.js new file mode 100644 index 000000000000..c63aee636ef7 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-fields/context-name/output.js @@ -0,0 +1,30 @@ +var _init_a, _init_a2, _init_computedKey, _computedKey, _init_computedKey2, _init_computedKey3, _computedKey2, _init_computedKey4, _init_computedKey5, _computedKey3, _init_computedKey6, _computedKey4, _init_computedKey7; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_init_a, _init_a2, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7] = babelHelpers.applyDecs2301(this, [[dec, 5, "a"], [dec, 5, "a", o => o.#a, (o, v) => o.#a = v], [dec, 5, "b"], [dec, 5, _computedKey], [dec, 5, 0], [dec, 5, _computedKey2], [dec, 5, 2n], [dec, 5, _computedKey3], [dec, 5, _computedKey4]], []).e; + } + static a = _init_a(this); + static #a = _init_a2(this); + static "b" = _init_computedKey(this); + static [_computedKey] = _init_computedKey2(this); + static 0 = _init_computedKey3(this); + static [_computedKey2] = _init_computedKey4(this); + static 2n = _init_computedKey5(this); + static [_computedKey3] = _init_computedKey6(this); + static [_computedKey4] = _init_computedKey7(this); +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..333a1d19d6a5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static get a() {}; + @dec static get #a() {}; + + @dec static get "b"() {} + @dec static get ["c"]() {}; + + @dec static get 0() {}; + @dec static get [1]() {}; + + @dec static get 2n() {}; + @dec static get [3n]() {}; + + @dec static get [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/context-name/input.js new file mode 100644 index 000000000000..333a1d19d6a5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static get a() {}; + @dec static get #a() {}; + + @dec static get "b"() {} + @dec static get ["c"]() {}; + + @dec static get 0() {}; + @dec static get [1]() {}; + + @dec static get 2n() {}; + @dec static get [3n]() {}; + + @dec static get [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/context-name/output.js new file mode 100644 index 000000000000..472bec3a497c --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters--to-es2015/context-name/output.js @@ -0,0 +1,38 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static get a() {} + static get "b"() {} + static get [_computedKey]() {} + static get 0() {} + static get [_computedKey2]() {} + static get 2n() {} + static get [_computedKey3]() {} + static get [_computedKey4]() {} +} +_class = Foo; +function _get_a() { + return _call_a(this); +} +var _a = { + get: _get_a, + set: void 0 +}; +(() => { + [_call_a, _initStatic] = babelHelpers.applyDecs2301(_class, [[dec, 8, "a"], [dec, 8, "a", function () {}], [dec, 8, "b"], [dec, 8, _computedKey], [dec, 8, 0], [dec, 8, _computedKey2], [dec, 8, 2n], [dec, 8, _computedKey3], [dec, 8, _computedKey4]], []).e; + _initStatic(_class); +})(); +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/context-name/exec.js new file mode 100644 index 000000000000..333a1d19d6a5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static get a() {}; + @dec static get #a() {}; + + @dec static get "b"() {} + @dec static get ["c"]() {}; + + @dec static get 0() {}; + @dec static get [1]() {}; + + @dec static get 2n() {}; + @dec static get [3n]() {}; + + @dec static get [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/context-name/input.js new file mode 100644 index 000000000000..333a1d19d6a5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static get a() {}; + @dec static get #a() {}; + + @dec static get "b"() {} + @dec static get ["c"]() {}; + + @dec static get 0() {}; + @dec static get [1]() {}; + + @dec static get 2n() {}; + @dec static get [3n]() {}; + + @dec static get [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/context-name/output.js new file mode 100644 index 000000000000..76ed85f6ce40 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-getters/context-name/output.js @@ -0,0 +1,33 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_call_a, _initStatic] = babelHelpers.applyDecs2301(this, [[dec, 8, "a"], [dec, 8, "a", function () {}], [dec, 8, "b"], [dec, 8, _computedKey], [dec, 8, 0], [dec, 8, _computedKey2], [dec, 8, 2n], [dec, 8, _computedKey3], [dec, 8, _computedKey4]], []).e; + _initStatic(this); + } + static get a() {} + static get #a() { + return _call_a(this); + } + static get "b"() {} + static get [_computedKey]() {} + static get 0() {} + static get [_computedKey2]() {} + static get 2n() {} + static get [_computedKey3]() {} + static get [_computedKey4]() {} +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..f22ec7c2e74a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a() {}; + @dec static #a() {}; + + @dec static "b"() {} + @dec static ["c"]() {}; + + @dec static 0() {}; + @dec static [1]() {}; + + @dec static 2n() {}; + @dec static [3n]() {}; + + @dec static [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/context-name/input.js new file mode 100644 index 000000000000..f22ec7c2e74a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a() {}; + @dec static #a() {}; + + @dec static "b"() {} + @dec static ["c"]() {}; + + @dec static 0() {}; + @dec static [1]() {}; + + @dec static 2n() {}; + @dec static [3n]() {}; + + @dec static [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/context-name/output.js new file mode 100644 index 000000000000..b8708a6dc8cf --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods--to-es2015/context-name/output.js @@ -0,0 +1,35 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static a() {} + static "b"() {} + static [_computedKey]() {} + static 0() {} + static [_computedKey2]() {} + static 2n() {} + static [_computedKey3]() {} + static [_computedKey4]() {} +} +_class = Foo; +(() => { + [_call_a, _initStatic] = babelHelpers.applyDecs2301(_class, [[dec, 7, "a"], [dec, 7, "a", function () {}], [dec, 7, "b"], [dec, 7, _computedKey], [dec, 7, 0], [dec, 7, _computedKey2], [dec, 7, 2n], [dec, 7, _computedKey3], [dec, 7, _computedKey4]], []).e; + _initStatic(_class); +})(); +var _a = { + writable: true, + value: _call_a +}; +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/context-name/exec.js new file mode 100644 index 000000000000..f22ec7c2e74a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a() {}; + @dec static #a() {}; + + @dec static "b"() {} + @dec static ["c"]() {}; + + @dec static 0() {}; + @dec static [1]() {}; + + @dec static 2n() {}; + @dec static [3n]() {}; + + @dec static [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/context-name/input.js new file mode 100644 index 000000000000..f22ec7c2e74a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a() {}; + @dec static #a() {}; + + @dec static "b"() {} + @dec static ["c"]() {}; + + @dec static 0() {}; + @dec static [1]() {}; + + @dec static 2n() {}; + @dec static [3n]() {}; + + @dec static [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/context-name/output.js new file mode 100644 index 000000000000..232b5cea26dd --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-methods/context-name/output.js @@ -0,0 +1,31 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_call_a, _initStatic] = babelHelpers.applyDecs2301(this, [[dec, 7, "a"], [dec, 7, "a", function () {}], [dec, 7, "b"], [dec, 7, _computedKey], [dec, 7, 0], [dec, 7, _computedKey2], [dec, 7, 2n], [dec, 7, _computedKey3], [dec, 7, _computedKey4]], []).e; + _initStatic(this); + } + static #a = _call_a; + static a() {} + static "b"() {} + static [_computedKey]() {} + static 0() {} + static [_computedKey2]() {} + static 2n() {} + static [_computedKey3]() {} + static [_computedKey4]() {} +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..5f2fc10d4634 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static set a(v) {}; + @dec static set #a(v) {}; + + @dec static set "b"(v) {} + @dec static set ["c"](v) {}; + + @dec static set 0(v) {}; + @dec static set [1](v) {}; + + @dec static set 2n(v) {}; + @dec static set [3n](v) {}; + + @dec static set [f()](v) {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/context-name/input.js new file mode 100644 index 000000000000..5f2fc10d4634 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static set a(v) {}; + @dec static set #a(v) {}; + + @dec static set "b"(v) {} + @dec static set ["c"](v) {}; + + @dec static set 0(v) {}; + @dec static set [1](v) {}; + + @dec static set 2n(v) {}; + @dec static set [3n](v) {}; + + @dec static set [f()](v) {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/context-name/output.js new file mode 100644 index 000000000000..a90e51364f68 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters--to-es2015/context-name/output.js @@ -0,0 +1,38 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static set a(v) {} + static set "b"(v) {} + static set [_computedKey](v) {} + static set 0(v) {} + static set [_computedKey2](v) {} + static set 2n(v) {} + static set [_computedKey3](v) {} + static set [_computedKey4](v) {} +} +_class = Foo; +function _set_a(v) { + _call_a(this, v); +} +var _a = { + get: void 0, + set: _set_a +}; +(() => { + [_call_a, _initStatic] = babelHelpers.applyDecs2301(_class, [[dec, 9, "a"], [dec, 9, "a", function (v) {}], [dec, 9, "b"], [dec, 9, _computedKey], [dec, 9, 0], [dec, 9, _computedKey2], [dec, 9, 2n], [dec, 9, _computedKey3], [dec, 9, _computedKey4]], []).e; + _initStatic(_class); +})(); +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/context-name/exec.js new file mode 100644 index 000000000000..5f2fc10d4634 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static set a(v) {}; + @dec static set #a(v) {}; + + @dec static set "b"(v) {} + @dec static set ["c"](v) {}; + + @dec static set 0(v) {}; + @dec static set [1](v) {}; + + @dec static set 2n(v) {}; + @dec static set [3n](v) {}; + + @dec static set [f()](v) {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/context-name/input.js new file mode 100644 index 000000000000..5f2fc10d4634 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static set a(v) {}; + @dec static set #a(v) {}; + + @dec static set "b"(v) {} + @dec static set ["c"](v) {}; + + @dec static set 0(v) {}; + @dec static set [1](v) {}; + + @dec static set 2n(v) {}; + @dec static set [3n](v) {}; + + @dec static set [f()](v) {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/context-name/output.js new file mode 100644 index 000000000000..bc60de9f6c64 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-setters/context-name/output.js @@ -0,0 +1,33 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_call_a, _initStatic] = babelHelpers.applyDecs2301(this, [[dec, 9, "a"], [dec, 9, "a", function (v) {}], [dec, 9, "b"], [dec, 9, _computedKey], [dec, 9, 0], [dec, 9, _computedKey2], [dec, 9, 2n], [dec, 9, _computedKey3], [dec, 9, _computedKey4]], []).e; + _initStatic(this); + } + static set a(v) {} + static set #a(v) { + _call_a(this, v); + } + static set "b"(v) {} + static set [_computedKey](v) {} + static set 0(v) {} + static set [_computedKey2](v) {} + static set 2n(v) {} + static set [_computedKey3](v) {} + static set [_computedKey4](v) {} +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..c2a1429d240d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static accessor a; + @dec static accessor #a; + + @dec static accessor "b" + @dec static accessor ["c"]; + + @dec static accessor 0; + @dec static accessor [1]; + + @dec static accessor 2n; + @dec static accessor [3n]; + + @dec static accessor [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/context-name/input.js new file mode 100644 index 000000000000..c2a1429d240d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static accessor a; + @dec static accessor #a; + + @dec static accessor "b" + @dec static accessor ["c"]; + + @dec static accessor 0; + @dec static accessor [1]; + + @dec static accessor 2n; + @dec static accessor [3n]; + + @dec static accessor [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/context-name/output.js new file mode 100644 index 000000000000..0809f272a7e4 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/context-name/output.js @@ -0,0 +1,120 @@ +var _init_a, _init_a2, _get_a, _set_a, _init_computedKey, _computedKey, _init_computedKey2, _init_computedKey3, _computedKey2, _init_computedKey4, _init_computedKey5, _computedKey3, _init_computedKey6, _computedKey4, _init_computedKey7, _initStatic, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +var _a = /*#__PURE__*/new WeakMap(); +class Foo { + constructor() { + babelHelpers.classPrivateFieldInitSpec(this, _a, { + get: _get_a2, + set: _set_a2 + }); + } + static get a() { + return babelHelpers.classStaticPrivateFieldSpecGet(Foo, Foo, _A); + } + static set a(v) { + babelHelpers.classStaticPrivateFieldSpecSet(Foo, Foo, _A, v); + } + static get "b"() { + return babelHelpers.classStaticPrivateFieldSpecGet(Foo, Foo, _C); + } + static set "b"(v) { + babelHelpers.classStaticPrivateFieldSpecSet(Foo, Foo, _C, v); + } + static get [_computedKey]() { + return babelHelpers.classStaticPrivateFieldSpecGet(Foo, Foo, _D); + } + static set [_computedKey](v) { + babelHelpers.classStaticPrivateFieldSpecSet(Foo, Foo, _D, v); + } + static get 0() { + return babelHelpers.classStaticPrivateFieldSpecGet(Foo, Foo, _E); + } + static set 0(v) { + babelHelpers.classStaticPrivateFieldSpecSet(Foo, Foo, _E, v); + } + static get [_computedKey2]() { + return babelHelpers.classStaticPrivateFieldSpecGet(Foo, Foo, _F); + } + static set [_computedKey2](v) { + babelHelpers.classStaticPrivateFieldSpecSet(Foo, Foo, _F, v); + } + static get 2n() { + return babelHelpers.classStaticPrivateFieldSpecGet(Foo, Foo, _G); + } + static set 2n(v) { + babelHelpers.classStaticPrivateFieldSpecSet(Foo, Foo, _G, v); + } + static get [_computedKey3]() { + return babelHelpers.classStaticPrivateFieldSpecGet(Foo, Foo, _H); + } + static set [_computedKey3](v) { + babelHelpers.classStaticPrivateFieldSpecSet(Foo, Foo, _H, v); + } + static get [_computedKey4]() { + return babelHelpers.classStaticPrivateFieldSpecGet(Foo, Foo, _I); + } + static set [_computedKey4](v) { + babelHelpers.classStaticPrivateFieldSpecSet(Foo, Foo, _I, v); + } +} +_class = Foo; +function _set_a2(v) { + _set_a(this, v); +} +function _get_a2() { + return _get_a(this); +} +(() => { + [_init_a, _init_a2, _get_a, _set_a, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7, _initStatic] = babelHelpers.applyDecs2305(_class, [[dec, 9, "a"], [dec, 9, "a", o => babelHelpers.classStaticPrivateFieldSpecGet(o, _class, _B), (o, v) => babelHelpers.classStaticPrivateFieldSpecSet(o, _class, _B, v)], [dec, 9, "b"], [dec, 9, _computedKey], [dec, 9, 0], [dec, 9, _computedKey2], [dec, 9, 2n], [dec, 9, _computedKey3], [dec, 9, _computedKey4]], []).e; + _initStatic(_class); +})(); +var _A = { + writable: true, + value: _init_a(_class) +}; +var _B = { + writable: true, + value: _init_a2(_class) +}; +var _C = { + writable: true, + value: _init_computedKey(_class) +}; +var _D = { + writable: true, + value: _init_computedKey2(_class) +}; +var _E = { + writable: true, + value: _init_computedKey3(_class) +}; +var _F = { + writable: true, + value: _init_computedKey4(_class) +}; +var _G = { + writable: true, + value: _init_computedKey5(_class) +}; +var _H = { + writable: true, + value: _init_computedKey6(_class) +}; +var _I = { + writable: true, + value: _init_computedKey7(_class) +}; +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/context-name/exec.js new file mode 100644 index 000000000000..c2a1429d240d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static accessor a; + @dec static accessor #a; + + @dec static accessor "b" + @dec static accessor ["c"]; + + @dec static accessor 0; + @dec static accessor [1]; + + @dec static accessor 2n; + @dec static accessor [3n]; + + @dec static accessor [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/context-name/input.js new file mode 100644 index 000000000000..c2a1429d240d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static accessor a; + @dec static accessor #a; + + @dec static accessor "b" + @dec static accessor ["c"]; + + @dec static accessor 0; + @dec static accessor [1]; + + @dec static accessor 2n; + @dec static accessor [3n]; + + @dec static accessor [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/context-name/output.js new file mode 100644 index 000000000000..d5030512f81c --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/context-name/output.js @@ -0,0 +1,85 @@ +var _init_a, _init_a2, _get_a, _set_a, _init_computedKey, _computedKey, _init_computedKey2, _init_computedKey3, _computedKey2, _init_computedKey4, _init_computedKey5, _computedKey3, _init_computedKey6, _computedKey4, _init_computedKey7, _initStatic; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_init_a, _init_a2, _get_a, _set_a, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7, _initStatic] = babelHelpers.applyDecs2305(this, [[dec, 9, "a"], [dec, 9, "a", o => o.#B, (o, v) => o.#B = v], [dec, 9, "b"], [dec, 9, _computedKey], [dec, 9, 0], [dec, 9, _computedKey2], [dec, 9, 2n], [dec, 9, _computedKey3], [dec, 9, _computedKey4]], []).e; + _initStatic(this); + } + static #A = _init_a(this); + static get a() { + return Foo.#A; + } + static set a(v) { + Foo.#A = v; + } + static #B = _init_a2(this); + set #a(v) { + _set_a(this, v); + } + get #a() { + return _get_a(this); + } + static #C = _init_computedKey(this); + static get "b"() { + return Foo.#C; + } + static set "b"(v) { + Foo.#C = v; + } + static #D = _init_computedKey2(this); + static get [_computedKey]() { + return Foo.#D; + } + static set [_computedKey](v) { + Foo.#D = v; + } + static #E = _init_computedKey3(this); + static get 0() { + return Foo.#E; + } + static set 0(v) { + Foo.#E = v; + } + static #F = _init_computedKey4(this); + static get [_computedKey2]() { + return Foo.#F; + } + static set [_computedKey2](v) { + Foo.#F = v; + } + static #G = _init_computedKey5(this); + static get 2n() { + return Foo.#G; + } + static set 2n(v) { + Foo.#G = v; + } + static #H = _init_computedKey6(this); + static get [_computedKey3]() { + return Foo.#H; + } + static set [_computedKey3](v) { + Foo.#H = v; + } + static #I = _init_computedKey7(this); + static get [_computedKey4]() { + return Foo.#I; + } + static set [_computedKey4](v) { + Foo.#I = v; + } +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..45a0db870f28 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a; + @dec static #a; + + @dec static "b" + @dec static ["c"]; + + @dec static 0; + @dec static [1]; + + @dec static 2n; + @dec static [3n]; + + @dec static [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields--to-es2015/context-name/input.js new file mode 100644 index 000000000000..45a0db870f28 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a; + @dec static #a; + + @dec static "b" + @dec static ["c"]; + + @dec static 0; + @dec static [1]; + + @dec static 2n; + @dec static [3n]; + + @dec static [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields--to-es2015/context-name/output.js new file mode 100644 index 000000000000..e1e25fb9da03 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields--to-es2015/context-name/output.js @@ -0,0 +1,31 @@ +var _init_a, _init_a2, _init_computedKey, _computedKey, _init_computedKey2, _init_computedKey3, _computedKey2, _init_computedKey4, _init_computedKey5, _computedKey3, _init_computedKey6, _computedKey4, _init_computedKey7, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo {} +_class = Foo; +[_init_a, _init_a2, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7] = babelHelpers.applyDecs2305(_class, [[dec, 8, "a"], [dec, 8, "a", o => babelHelpers.classStaticPrivateFieldSpecGet(o, _class, _a), (o, v) => babelHelpers.classStaticPrivateFieldSpecSet(o, _class, _a, v)], [dec, 8, "b"], [dec, 8, _computedKey], [dec, 8, 0], [dec, 8, _computedKey2], [dec, 8, 2n], [dec, 8, _computedKey3], [dec, 8, _computedKey4]], []).e; +babelHelpers.defineProperty(Foo, "a", _init_a(_class)); +var _a = { + writable: true, + value: _init_a2(_class) +}; +babelHelpers.defineProperty(Foo, "b", _init_computedKey(_class)); +babelHelpers.defineProperty(Foo, _computedKey, _init_computedKey2(_class)); +babelHelpers.defineProperty(Foo, 0, _init_computedKey3(_class)); +babelHelpers.defineProperty(Foo, _computedKey2, _init_computedKey4(_class)); +babelHelpers.defineProperty(Foo, 2n, _init_computedKey5(_class)); +babelHelpers.defineProperty(Foo, _computedKey3, _init_computedKey6(_class)); +babelHelpers.defineProperty(Foo, _computedKey4, _init_computedKey7(_class)); +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields/context-name/exec.js new file mode 100644 index 000000000000..45a0db870f28 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a; + @dec static #a; + + @dec static "b" + @dec static ["c"]; + + @dec static 0; + @dec static [1]; + + @dec static 2n; + @dec static [3n]; + + @dec static [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields/context-name/input.js new file mode 100644 index 000000000000..45a0db870f28 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a; + @dec static #a; + + @dec static "b" + @dec static ["c"]; + + @dec static 0; + @dec static [1]; + + @dec static 2n; + @dec static [3n]; + + @dec static [f()]; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields/context-name/output.js new file mode 100644 index 000000000000..663081a1a13b --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-fields/context-name/output.js @@ -0,0 +1,30 @@ +var _init_a, _init_a2, _init_computedKey, _computedKey, _init_computedKey2, _init_computedKey3, _computedKey2, _init_computedKey4, _init_computedKey5, _computedKey3, _init_computedKey6, _computedKey4, _init_computedKey7; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_init_a, _init_a2, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7] = babelHelpers.applyDecs2305(this, [[dec, 8, "a"], [dec, 8, "a", o => o.#a, (o, v) => o.#a = v], [dec, 8, "b"], [dec, 8, _computedKey], [dec, 8, 0], [dec, 8, _computedKey2], [dec, 8, 2n], [dec, 8, _computedKey3], [dec, 8, _computedKey4]], []).e; + } + static a = _init_a(this); + static #a = _init_a2(this); + static "b" = _init_computedKey(this); + static [_computedKey] = _init_computedKey2(this); + static 0 = _init_computedKey3(this); + static [_computedKey2] = _init_computedKey4(this); + static 2n = _init_computedKey5(this); + static [_computedKey3] = _init_computedKey6(this); + static [_computedKey4] = _init_computedKey7(this); +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..333a1d19d6a5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static get a() {}; + @dec static get #a() {}; + + @dec static get "b"() {} + @dec static get ["c"]() {}; + + @dec static get 0() {}; + @dec static get [1]() {}; + + @dec static get 2n() {}; + @dec static get [3n]() {}; + + @dec static get [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters--to-es2015/context-name/input.js new file mode 100644 index 000000000000..333a1d19d6a5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static get a() {}; + @dec static get #a() {}; + + @dec static get "b"() {} + @dec static get ["c"]() {}; + + @dec static get 0() {}; + @dec static get [1]() {}; + + @dec static get 2n() {}; + @dec static get [3n]() {}; + + @dec static get [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters--to-es2015/context-name/output.js new file mode 100644 index 000000000000..2cb06f26b5ba --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters--to-es2015/context-name/output.js @@ -0,0 +1,38 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static get a() {} + static get "b"() {} + static get [_computedKey]() {} + static get 0() {} + static get [_computedKey2]() {} + static get 2n() {} + static get [_computedKey3]() {} + static get [_computedKey4]() {} +} +_class = Foo; +function _get_a() { + return _call_a(this); +} +var _a = { + get: _get_a, + set: void 0 +}; +(() => { + [_call_a, _initStatic] = babelHelpers.applyDecs2305(_class, [[dec, 11, "a"], [dec, 11, "a", function () {}], [dec, 11, "b"], [dec, 11, _computedKey], [dec, 11, 0], [dec, 11, _computedKey2], [dec, 11, 2n], [dec, 11, _computedKey3], [dec, 11, _computedKey4]], []).e; + _initStatic(_class); +})(); +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters/context-name/exec.js new file mode 100644 index 000000000000..333a1d19d6a5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static get a() {}; + @dec static get #a() {}; + + @dec static get "b"() {} + @dec static get ["c"]() {}; + + @dec static get 0() {}; + @dec static get [1]() {}; + + @dec static get 2n() {}; + @dec static get [3n]() {}; + + @dec static get [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters/context-name/input.js new file mode 100644 index 000000000000..333a1d19d6a5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static get a() {}; + @dec static get #a() {}; + + @dec static get "b"() {} + @dec static get ["c"]() {}; + + @dec static get 0() {}; + @dec static get [1]() {}; + + @dec static get 2n() {}; + @dec static get [3n]() {}; + + @dec static get [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters/context-name/output.js new file mode 100644 index 000000000000..2d5cff9aacda --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-getters/context-name/output.js @@ -0,0 +1,33 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_call_a, _initStatic] = babelHelpers.applyDecs2305(this, [[dec, 11, "a"], [dec, 11, "a", function () {}], [dec, 11, "b"], [dec, 11, _computedKey], [dec, 11, 0], [dec, 11, _computedKey2], [dec, 11, 2n], [dec, 11, _computedKey3], [dec, 11, _computedKey4]], []).e; + _initStatic(this); + } + static get a() {} + static get #a() { + return _call_a(this); + } + static get "b"() {} + static get [_computedKey]() {} + static get 0() {} + static get [_computedKey2]() {} + static get 2n() {} + static get [_computedKey3]() {} + static get [_computedKey4]() {} +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..f22ec7c2e74a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a() {}; + @dec static #a() {}; + + @dec static "b"() {} + @dec static ["c"]() {}; + + @dec static 0() {}; + @dec static [1]() {}; + + @dec static 2n() {}; + @dec static [3n]() {}; + + @dec static [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods--to-es2015/context-name/input.js new file mode 100644 index 000000000000..f22ec7c2e74a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a() {}; + @dec static #a() {}; + + @dec static "b"() {} + @dec static ["c"]() {}; + + @dec static 0() {}; + @dec static [1]() {}; + + @dec static 2n() {}; + @dec static [3n]() {}; + + @dec static [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods--to-es2015/context-name/output.js new file mode 100644 index 000000000000..73fbfe59c960 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods--to-es2015/context-name/output.js @@ -0,0 +1,35 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static a() {} + static "b"() {} + static [_computedKey]() {} + static 0() {} + static [_computedKey2]() {} + static 2n() {} + static [_computedKey3]() {} + static [_computedKey4]() {} +} +_class = Foo; +(() => { + [_call_a, _initStatic] = babelHelpers.applyDecs2305(_class, [[dec, 10, "a"], [dec, 10, "a", function () {}], [dec, 10, "b"], [dec, 10, _computedKey], [dec, 10, 0], [dec, 10, _computedKey2], [dec, 10, 2n], [dec, 10, _computedKey3], [dec, 10, _computedKey4]], []).e; + _initStatic(_class); +})(); +var _a = { + writable: true, + value: _call_a +}; +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods/context-name/exec.js new file mode 100644 index 000000000000..f22ec7c2e74a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a() {}; + @dec static #a() {}; + + @dec static "b"() {} + @dec static ["c"]() {}; + + @dec static 0() {}; + @dec static [1]() {}; + + @dec static 2n() {}; + @dec static [3n]() {}; + + @dec static [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods/context-name/input.js new file mode 100644 index 000000000000..f22ec7c2e74a --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static a() {}; + @dec static #a() {}; + + @dec static "b"() {} + @dec static ["c"]() {}; + + @dec static 0() {}; + @dec static [1]() {}; + + @dec static 2n() {}; + @dec static [3n]() {}; + + @dec static [f()]() {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods/context-name/output.js new file mode 100644 index 000000000000..c2dd4150235d --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-methods/context-name/output.js @@ -0,0 +1,31 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_call_a, _initStatic] = babelHelpers.applyDecs2305(this, [[dec, 10, "a"], [dec, 10, "a", function () {}], [dec, 10, "b"], [dec, 10, _computedKey], [dec, 10, 0], [dec, 10, _computedKey2], [dec, 10, 2n], [dec, 10, _computedKey3], [dec, 10, _computedKey4]], []).e; + _initStatic(this); + } + static #a = _call_a; + static a() {} + static "b"() {} + static [_computedKey]() {} + static 0() {} + static [_computedKey2]() {} + static 2n() {} + static [_computedKey3]() {} + static [_computedKey4]() {} +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters--to-es2015/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters--to-es2015/context-name/exec.js new file mode 100644 index 000000000000..5f2fc10d4634 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters--to-es2015/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static set a(v) {}; + @dec static set #a(v) {}; + + @dec static set "b"(v) {} + @dec static set ["c"](v) {}; + + @dec static set 0(v) {}; + @dec static set [1](v) {}; + + @dec static set 2n(v) {}; + @dec static set [3n](v) {}; + + @dec static set [f()](v) {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters--to-es2015/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters--to-es2015/context-name/input.js new file mode 100644 index 000000000000..5f2fc10d4634 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters--to-es2015/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static set a(v) {}; + @dec static set #a(v) {}; + + @dec static set "b"(v) {} + @dec static set ["c"](v) {}; + + @dec static set 0(v) {}; + @dec static set [1](v) {}; + + @dec static set 2n(v) {}; + @dec static set [3n](v) {}; + + @dec static set [f()](v) {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters--to-es2015/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters--to-es2015/context-name/options.json new file mode 100644 index 000000000000..a5bead3a49f5 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters--to-es2015/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "14.6.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters--to-es2015/context-name/output.js new file mode 100644 index 000000000000..a1549a4c19e3 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters--to-es2015/context-name/output.js @@ -0,0 +1,38 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic, _class; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static set a(v) {} + static set "b"(v) {} + static set [_computedKey](v) {} + static set 0(v) {} + static set [_computedKey2](v) {} + static set 2n(v) {} + static set [_computedKey3](v) {} + static set [_computedKey4](v) {} +} +_class = Foo; +function _set_a(v) { + _call_a(this, v); +} +var _a = { + get: void 0, + set: _set_a +}; +(() => { + [_call_a, _initStatic] = babelHelpers.applyDecs2305(_class, [[dec, 12, "a"], [dec, 12, "a", function (v) {}], [dec, 12, "b"], [dec, 12, _computedKey], [dec, 12, 0], [dec, 12, _computedKey2], [dec, 12, 2n], [dec, 12, _computedKey3], [dec, 12, _computedKey4]], []).e; + _initStatic(_class); +})(); +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters/context-name/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters/context-name/exec.js new file mode 100644 index 000000000000..5f2fc10d4634 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters/context-name/exec.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static set a(v) {}; + @dec static set #a(v) {}; + + @dec static set "b"(v) {} + @dec static set ["c"](v) {}; + + @dec static set 0(v) {}; + @dec static set [1](v) {}; + + @dec static set 2n(v) {}; + @dec static set [3n](v) {}; + + @dec static set [f()](v) {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters/context-name/input.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters/context-name/input.js new file mode 100644 index 000000000000..5f2fc10d4634 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters/context-name/input.js @@ -0,0 +1,20 @@ +const logs = []; +const dec = (value, context) => { logs.push(context.name) }; +const f = () => { logs.push("computing f"); return { [Symbol.toPrimitive]: () => "f()" }; }; +class Foo { + @dec static set a(v) {}; + @dec static set #a(v) {}; + + @dec static set "b"(v) {} + @dec static set ["c"](v) {}; + + @dec static set 0(v) {}; + @dec static set [1](v) {}; + + @dec static set 2n(v) {}; + @dec static set [3n](v) {}; + + @dec static set [f()](v) {}; +} + +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters/context-name/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters/context-name/options.json new file mode 100644 index 000000000000..f97653393918 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters/context-name/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "16.11.0" +} diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters/context-name/output.js new file mode 100644 index 000000000000..b754c0da5069 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-setters/context-name/output.js @@ -0,0 +1,33 @@ +var _call_a, _computedKey, _computedKey2, _computedKey3, _computedKey4, _initStatic; +const logs = []; +const dec = (value, context) => { + logs.push(context.name); +}; +const f = () => { + logs.push("computing f"); + return { + [Symbol.toPrimitive]: () => "f()" + }; +}; +_computedKey = "c"; +_computedKey2 = 1; +_computedKey3 = 3n; +_computedKey4 = f(); +class Foo { + static { + [_call_a, _initStatic] = babelHelpers.applyDecs2305(this, [[dec, 12, "a"], [dec, 12, "a", function (v) {}], [dec, 12, "b"], [dec, 12, _computedKey], [dec, 12, 0], [dec, 12, _computedKey2], [dec, 12, 2n], [dec, 12, _computedKey3], [dec, 12, _computedKey4]], []).e; + _initStatic(this); + } + static set a(v) {} + static set #a(v) { + _call_a(this, v); + } + static set "b"(v) {} + static set [_computedKey](v) {} + static set 0(v) {} + static set [_computedKey2](v) {} + static set 2n(v) {} + static set [_computedKey3](v) {} + static set [_computedKey4](v) {} +} +expect(logs).toStrictEqual(["computing f", "a", "#a", "b", "c", "0", "1", "2", "3", "f()"]); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/class-shadow-builtins/output.mjs b/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/class-shadow-builtins/output.mjs index 9debdcf55680..5f0349304e29 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/class-shadow-builtins/output.mjs +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public-loose/class-shadow-builtins/output.mjs @@ -1,6 +1,6 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); } +function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } class _TypeError { constructor() { _defineProperty(this, "message", void 0); diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/public/class-shadow-builtins/output.mjs b/packages/babel-plugin-transform-class-properties/test/fixtures/public/class-shadow-builtins/output.mjs index 9debdcf55680..5f0349304e29 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/public/class-shadow-builtins/output.mjs +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/public/class-shadow-builtins/output.mjs @@ -1,6 +1,6 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); } +function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } class _TypeError { constructor() { _defineProperty(this, "message", void 0); diff --git a/packages/babel-plugin-transform-class-static-block/test/plugin-ordering.test.js b/packages/babel-plugin-transform-class-static-block/test/plugin-ordering.test.js index a796dcf1b4c0..88ed944bac14 100644 --- a/packages/babel-plugin-transform-class-static-block/test/plugin-ordering.test.js +++ b/packages/babel-plugin-transform-class-static-block/test/plugin-ordering.test.js @@ -22,8 +22,8 @@ describe("plugin ordering", () => { ).toMatchInlineSnapshot(` "var _class; function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - function _toPropertyKey(arg) { var key = _toPrimitive(arg, \\"string\\"); return typeof key === \\"symbol\\" ? key : String(key); } - function _toPrimitive(input, hint) { if (typeof input !== \\"object\\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \\"default\\"); if (typeof res !== \\"object\\") return res; throw new TypeError(\\"@@toPrimitive must return a primitive value.\\"); } return (hint === \\"string\\" ? String : Number)(input); } + function _toPropertyKey(t) { var i = _toPrimitive(t, \\"string\\"); return \\"symbol\\" == typeof i ? i : String(i); } + function _toPrimitive(t, r) { if (\\"object\\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \\"default\\"); if (\\"object\\" != typeof i) return i; throw new TypeError(\\"@@toPrimitive must return a primitive value.\\"); } return (\\"string\\" === r ? String : Number)(t); } class Foo {} _class = Foo; _class.foo = _class.bar; diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/runtime-corejs2/no-helpers/output.js b/packages/babel-plugin-transform-runtime/test/fixtures/runtime-corejs2/no-helpers/output.js index 1ec21b0fbc54..d324018e7e0b 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/runtime-corejs2/no-helpers/output.js +++ b/packages/babel-plugin-transform-runtime/test/fixtures/runtime-corejs2/no-helpers/output.js @@ -2,8 +2,8 @@ var _Symbol$toPrimitive = require("@babel/runtime-corejs2/core-js/symbol/to-prim var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property"); function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; _Object$defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); _Object$defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[_Symbol$toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); } +function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[_Symbol$toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } let Foo = /*#__PURE__*/_createClass(function Foo() { "use strict"; diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/runtime-corejs3/no-helpers/output.js b/packages/babel-plugin-transform-runtime/test/fixtures/runtime-corejs3/no-helpers/output.js index 1b9b57425c46..ff71e52ba166 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/runtime-corejs3/no-helpers/output.js +++ b/packages/babel-plugin-transform-runtime/test/fixtures/runtime-corejs3/no-helpers/output.js @@ -2,8 +2,8 @@ var _Symbol$toPrimitive = require("@babel/runtime-corejs3/core-js-stable/symbol/ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; _Object$defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); _Object$defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[_Symbol$toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); } +function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[_Symbol$toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } let Foo = /*#__PURE__*/_createClass(function Foo() { "use strict"; diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/runtime/no-helpers/output.js b/packages/babel-plugin-transform-runtime/test/fixtures/runtime/no-helpers/output.js index a06ccafc0ffc..dc6eabdfe6d2 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/runtime/no-helpers/output.js +++ b/packages/babel-plugin-transform-runtime/test/fixtures/runtime/no-helpers/output.js @@ -1,7 +1,7 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); } +function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } let Foo = /*#__PURE__*/_createClass(function Foo() { "use strict"; diff --git a/packages/babel-preset-env/test/fixtures/corejs2-babel-7/usage-shippedProposals/output.js b/packages/babel-preset-env/test/fixtures/corejs2-babel-7/usage-shippedProposals/output.js index a57ecf9385c5..673a28b81dfd 100644 --- a/packages/babel-preset-env/test/fixtures/corejs2-babel-7/usage-shippedProposals/output.js +++ b/packages/babel-preset-env/test/fixtures/corejs2-babel-7/usage-shippedProposals/output.js @@ -26,8 +26,8 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } +function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } function _awaitAsyncGenerator(e) { return new _OverloadYield(e, 0); } diff --git a/packages/babel-runtime-corejs2/package.json b/packages/babel-runtime-corejs2/package.json index 59c47dc588db..c0785e50ae87 100644 --- a/packages/babel-runtime-corejs2/package.json +++ b/packages/babel-runtime-corejs2/package.json @@ -198,6 +198,24 @@ "./helpers/regeneratorRuntime.js" ], "./helpers/esm/regeneratorRuntime": "./helpers/esm/regeneratorRuntime.js", + "./helpers/toPrimitive": [ + { + "node": "./helpers/toPrimitive.js", + "import": "./helpers/esm/toPrimitive.js", + "default": "./helpers/toPrimitive.js" + }, + "./helpers/toPrimitive.js" + ], + "./helpers/esm/toPrimitive": "./helpers/esm/toPrimitive.js", + "./helpers/toPropertyKey": [ + { + "node": "./helpers/toPropertyKey.js", + "import": "./helpers/esm/toPropertyKey.js", + "default": "./helpers/toPropertyKey.js" + }, + "./helpers/toPropertyKey.js" + ], + "./helpers/esm/toPropertyKey": "./helpers/esm/toPropertyKey.js", "./helpers/typeof": [ { "node": "./helpers/typeof.js", @@ -702,24 +720,6 @@ "./helpers/skipFirstGeneratorNext.js" ], "./helpers/esm/skipFirstGeneratorNext": "./helpers/esm/skipFirstGeneratorNext.js", - "./helpers/toPrimitive": [ - { - "node": "./helpers/toPrimitive.js", - "import": "./helpers/esm/toPrimitive.js", - "default": "./helpers/toPrimitive.js" - }, - "./helpers/toPrimitive.js" - ], - "./helpers/esm/toPrimitive": "./helpers/esm/toPrimitive.js", - "./helpers/toPropertyKey": [ - { - "node": "./helpers/toPropertyKey.js", - "import": "./helpers/esm/toPropertyKey.js", - "default": "./helpers/toPropertyKey.js" - }, - "./helpers/toPropertyKey.js" - ], - "./helpers/esm/toPropertyKey": "./helpers/esm/toPropertyKey.js", "./helpers/initializerWarningHelper": [ { "node": "./helpers/initializerWarningHelper.js", diff --git a/packages/babel-runtime-corejs3/package.json b/packages/babel-runtime-corejs3/package.json index 29b755fc3ece..e50b4de2c933 100644 --- a/packages/babel-runtime-corejs3/package.json +++ b/packages/babel-runtime-corejs3/package.json @@ -197,6 +197,24 @@ "./helpers/regeneratorRuntime.js" ], "./helpers/esm/regeneratorRuntime": "./helpers/esm/regeneratorRuntime.js", + "./helpers/toPrimitive": [ + { + "node": "./helpers/toPrimitive.js", + "import": "./helpers/esm/toPrimitive.js", + "default": "./helpers/toPrimitive.js" + }, + "./helpers/toPrimitive.js" + ], + "./helpers/esm/toPrimitive": "./helpers/esm/toPrimitive.js", + "./helpers/toPropertyKey": [ + { + "node": "./helpers/toPropertyKey.js", + "import": "./helpers/esm/toPropertyKey.js", + "default": "./helpers/toPropertyKey.js" + }, + "./helpers/toPropertyKey.js" + ], + "./helpers/esm/toPropertyKey": "./helpers/esm/toPropertyKey.js", "./helpers/typeof": [ { "node": "./helpers/typeof.js", @@ -701,24 +719,6 @@ "./helpers/skipFirstGeneratorNext.js" ], "./helpers/esm/skipFirstGeneratorNext": "./helpers/esm/skipFirstGeneratorNext.js", - "./helpers/toPrimitive": [ - { - "node": "./helpers/toPrimitive.js", - "import": "./helpers/esm/toPrimitive.js", - "default": "./helpers/toPrimitive.js" - }, - "./helpers/toPrimitive.js" - ], - "./helpers/esm/toPrimitive": "./helpers/esm/toPrimitive.js", - "./helpers/toPropertyKey": [ - { - "node": "./helpers/toPropertyKey.js", - "import": "./helpers/esm/toPropertyKey.js", - "default": "./helpers/toPropertyKey.js" - }, - "./helpers/toPropertyKey.js" - ], - "./helpers/esm/toPropertyKey": "./helpers/esm/toPropertyKey.js", "./helpers/initializerWarningHelper": [ { "node": "./helpers/initializerWarningHelper.js", diff --git a/packages/babel-runtime/package.json b/packages/babel-runtime/package.json index 783a19e8bd40..d6d2a74ba5d2 100644 --- a/packages/babel-runtime/package.json +++ b/packages/babel-runtime/package.json @@ -197,6 +197,24 @@ "./helpers/regeneratorRuntime.js" ], "./helpers/esm/regeneratorRuntime": "./helpers/esm/regeneratorRuntime.js", + "./helpers/toPrimitive": [ + { + "node": "./helpers/toPrimitive.js", + "import": "./helpers/esm/toPrimitive.js", + "default": "./helpers/toPrimitive.js" + }, + "./helpers/toPrimitive.js" + ], + "./helpers/esm/toPrimitive": "./helpers/esm/toPrimitive.js", + "./helpers/toPropertyKey": [ + { + "node": "./helpers/toPropertyKey.js", + "import": "./helpers/esm/toPropertyKey.js", + "default": "./helpers/toPropertyKey.js" + }, + "./helpers/toPropertyKey.js" + ], + "./helpers/esm/toPropertyKey": "./helpers/esm/toPropertyKey.js", "./helpers/typeof": [ { "node": "./helpers/typeof.js", @@ -701,24 +719,6 @@ "./helpers/skipFirstGeneratorNext.js" ], "./helpers/esm/skipFirstGeneratorNext": "./helpers/esm/skipFirstGeneratorNext.js", - "./helpers/toPrimitive": [ - { - "node": "./helpers/toPrimitive.js", - "import": "./helpers/esm/toPrimitive.js", - "default": "./helpers/toPrimitive.js" - }, - "./helpers/toPrimitive.js" - ], - "./helpers/esm/toPrimitive": "./helpers/esm/toPrimitive.js", - "./helpers/toPropertyKey": [ - { - "node": "./helpers/toPropertyKey.js", - "import": "./helpers/esm/toPropertyKey.js", - "default": "./helpers/toPropertyKey.js" - }, - "./helpers/toPropertyKey.js" - ], - "./helpers/esm/toPropertyKey": "./helpers/esm/toPropertyKey.js", "./helpers/initializerWarningHelper": [ { "node": "./helpers/initializerWarningHelper.js", diff --git a/packages/babel-types/src/definitions/core.ts b/packages/babel-types/src/definitions/core.ts index 96033ecd6466..39d7d09fbe39 100644 --- a/packages/babel-types/src/definitions/core.ts +++ b/packages/babel-types/src/definitions/core.ts @@ -1896,6 +1896,7 @@ export const classMethodOrPropertyCommon = () => ({ "Identifier", "StringLiteral", "NumericLiteral", + "BigIntLiteral", ); const computed = assertNodeType("Expression");