Skip to content

Commit

Permalink
Implement setComputedProperties assumption (#12490)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Jan 24, 2021
1 parent f69e918 commit 7057f03
Show file tree
Hide file tree
Showing 30 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/babel-core/src/config/validation/options.js
Expand Up @@ -335,6 +335,7 @@ export const assumptionsNames = new Set<string>([
"ignoreToPrimitiveHint",
"mutableTemplateObject",
"setClassMethods",
"setComputedProperties",
"setPublicClassFields",
]);

Expand Down
Expand Up @@ -4,8 +4,10 @@ import { template, types as t } from "@babel/core";
export default declare((api, options) => {
api.assertVersion(7);

const { loose } = options;
const pushComputedProps = loose
const setComputedProperties =
api.assumption("setComputedProperties") ?? options.loose;

const pushComputedProps = setComputedProperties
? pushComputedPropsLoose
: pushComputedPropsSpec;

Expand Down
@@ -0,0 +1,9 @@
{
"plugins": [
"external-helpers",
"transform-computed-properties"
],
"assumptions": {
"setComputedProperties": true
}
}
@@ -0,0 +1,4 @@
var obj = {
["x" + foo]: "heh",
["y" + bar]: "noo"
};
@@ -0,0 +1,3 @@
var _obj;

var obj = (_obj = {}, _obj["x" + foo] = "heh", _obj["y" + bar] = "noo", _obj);

0 comments on commit 7057f03

Please sign in to comment.