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

Do not warn for loose of class features in preset-env #12898

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
Expand Up @@ -29,6 +29,7 @@
},
"devDependencies": {
"@babel/core": "workspace:*",
"@babel/helper-plugin-test-runner": "workspace:*"
"@babel/helper-plugin-test-runner": "workspace:*",
"@babel/preset-env": "workspace:*"
}
}
Expand Up @@ -44,7 +44,11 @@ export function createClassFeaturePlugin({
const constantSuper = api.assumption("constantSuper");
const noDocumentAll = api.assumption("noDocumentAll");

if (loose) {
if (
loose === true ||
loose ===
"#__internal__@babel/preset-env__prefer-true-but-false-is-ok-if-it-prevents-an-error"
) {
const explicit = [];

if (setPublicClassFields !== undefined) {
Expand Down
@@ -0,0 +1,3 @@
class A {
foo;
}
@@ -0,0 +1,8 @@
{
"validateLogs": true,
"presets": [["env", { "shippedProposals": true }]],
"assumptions": {
"setPublicClassFields": true
},
"targets": "chrome 70"
}
@@ -0,0 +1,6 @@
class A {
constructor() {
this.foo = void 0;
}

}
@@ -0,0 +1 @@

@@ -0,0 +1,3 @@
class A {
foo;
}
@@ -0,0 +1,8 @@
{
"validateLogs": true,
"presets": [["env", { "loose": true, "shippedProposals": true }]],
"assumptions": {
"setPublicClassFields": true
},
"targets": "chrome 70"
}
@@ -0,0 +1,6 @@
class A {
constructor() {
this.foo = void 0;
}

}
@@ -0,0 +1,10 @@
[proposal-class-properties]: You are using the "loose: true" option and you are explicitly setting a value for the "setPublicClassFields" assumption. The "loose" option can cause incompatibilities with the other class features plugins, so it's recommended that you replace it with the following top-level option:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should also disable this warning?
It's explicitly setting loose: true, but in @babel/preset-env.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah

"assumptions": {
"setPublicClassFields": true,
"privateFieldsAsProperties": true
}
[proposal-private-methods]: You are using the "loose: true" option and you are explicitly setting a value for the "setPublicClassFields" assumption. The "loose" option can cause incompatibilities with the other class features plugins, so it's recommended that you replace it with the following top-level option:
"assumptions": {
"setPublicClassFields": true,
"privateFieldsAsProperties": true
}
1 change: 1 addition & 0 deletions yarn.lock
Expand Up @@ -429,6 +429,7 @@ __metadata:
"@babel/helper-plugin-test-runner": "workspace:*"
"@babel/helper-replace-supers": "workspace:^7.13.0"
"@babel/helper-split-export-declaration": "workspace:^7.12.13"
"@babel/preset-env": "workspace:*"
peerDependencies:
"@babel/core": ^7.0.0
languageName: unknown
Expand Down