Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement setComputedProperties assumption #12490

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);