to your Babel config.

This warning is being shown because the "loose" option is set to "false" for @babel/preset-env, but it is set to "true" for @babel/plugin-transform-private-methods. Since @babel/plugin-transform-private-property-in-object depends on @babel/plugin-transform-private-methods, the "loose" option must be the same for both.

To silence this warning, you need to explicitly add the configuration for @babel/plugin-transform-private-property-in-object to your Babel config and set the "loose" option to "true". Here's an example:

{
  "presets": [
    ["@babel/preset-env", {
      "loose": false
    }]
  ],
  "plugins": [
    ["@babel/plugin-transform-class-properties", {
      "loose": false
    }],
    ["@babel/plugin-transform-private-methods", {
      "loose": true
    }],
    ["@babel/plugin-transform-private-property-in-object", {
      "loose": true
    }]
  ]
}

By setting "loose" to "true" for all three plugins, you will no longer see this warning

jest 单元测试Though the loose option was set to false in your babelpreset-env config it will not be used for babelplugin-transform-private-property-in-object since the loose mode option was set to true fo

原文地址: http://www.cveoy.top/t/topic/h04m 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录