Skip to content
This repository has been archived by the owner on Jul 25, 2023. It is now read-only.

Commit

Permalink
Support for defineEnumerableProperties
Browse files Browse the repository at this point in the history
Summary:
**Motivation**
detailed in facebook#12702.

**Test plan**
1) running [a piece of code](mobxjs/mobx#839 (comment)) that utilizes the helper without any modifications on the react native package results an error being thrown.

![b589a71c-0041-11e7-9d47-cb79efff3ba5](https://cloud.githubusercontent.com/assets/23000873/23579517/3c8fe992-0100-11e7-9eb5-93c47f3df3e0.png)

2) updating the list of helpers available by adding the definition of `defineEnumerableProperties` as provided by babel [babel/babel/packages/babel-helpers/src/helpers.js](https://github.com/babel/babel/blob/master/packages/babel-helpers/src/helpers.js#L275-L285) results no errors.

![kapture 2017-03-04 at 16 48 35](https://cloud.githubusercontent.com/assets/23000873/23579520/457b8ca0-0100-11e7-8ca4-c704c6e9631f.gif)
Closes facebook#12703

Differential Revision: D4658120

Pulled By: ericvicenti

fbshipit-source-id: 914aed4d313b3cc4f7ab99049d05d0aef269a3be
  • Loading branch information
sonaye authored and jaredru committed May 9, 2017
1 parent b9f1e8b commit 38425b8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packager/src/Resolver/polyfills/babelHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ babelHelpers.createClass = (function () {
};
})();

babelHelpers.defineEnumerableProperties = function(obj, descs) {
for (var key in descs) {
var desc = descs[key];
desc.configurable = (desc.enumerable = true);
if ('value' in desc) desc.writable = true;
Object.defineProperty(obj, key, desc);
}
return obj;
};

babelHelpers.defineProperty = function (obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
Expand Down

0 comments on commit 38425b8

Please sign in to comment.