Skip to content

When I use ”#“ private method in class, it will not be compiled through and an error will be thrown: support for the experimental syntax 'classprivatemethods' isn't currently enabled . I can make sure that this problem occurs in the definition of private method. If you delete it, there will be no error #5304

@BARMPlus

Description

@BARMPlus

Version

4.2.3

Reproduction link

https://github.com/ccz-Eric/error-issues

Environment info

  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0 
    @vue/babel-plugin-transform-vue-jsx:  1.1.2 
    @vue/babel-preset-app:  4.2.3 
    @vue/babel-preset-jsx:  1.1.2 
    @vue/babel-sugar-functional-vue:  1.1.2 
    @vue/babel-sugar-inject-h:  1.1.2 
    @vue/babel-sugar-v-model:  1.1.2 
    @vue/babel-sugar-v-on:  1.1.2 
    @vue/cli-overlay:  4.2.3 
    @vue/cli-plugin-babel: ~4.2.0 => 4.2.3 
    @vue/cli-plugin-eslint: ~4.2.0 => 4.2.3 
    @vue/cli-plugin-router:  4.2.3 
    @vue/cli-plugin-vuex:  4.2.3 
    @vue/cli-service: ~4.2.0 => 4.2.3 
    @vue/cli-shared-utils:  4.2.3 
    @vue/component-compiler-utils:  3.1.1 
    @vue/preload-webpack-plugin:  1.1.1 
    @vue/web-component-wrapper:  1.2.0 
    eslint-plugin-vue: ^6.1.2 => 6.2.2 
    vue: ^2.6.11 => 2.6.11 
    vue-eslint-parser:  7.0.0 
    vue-hot-reload-api:  2.3.4 
    vue-loader:  15.9.0 
    vue-style-loader:  4.1.2 
    vue-template-compiler: ^2.6.11 => 2.6.11 
    vue-template-es2015-compiler:  1.9.1 
    vue-virtual-scroll-list: ^1.4.6 => 1.4.6 
    vuex: ^3.1.3 => 3.1.3 
  npmGlobalPackages:
    @vue/cli: 4.2.3

Steps to reproduce

Steps to reproduce the behavior:
class Foo { #a; #b; constructor(a, b) { this.#a = a; this.#b = b; } #sum() { return #a #b; } printSum() { console.log(this.#sum()); } }

What is expected?

Code works

What is actually happening?

Throw out error ”upport for the experimental syntax 'classprivatemethods' isn't currently enabled“


The following changes have been made, and error reporting cannot be resolved
package.json
"devDependencies": { "@babel/plugin-proposal-class-properties": "^7.8.3", ... },
babel.config.js
module.exports = { presets: [ '@vue/cli-plugin-babel/preset' ], plugins: [ "@babel/plugin-proposal-class-properties" ] }

Unfortunately, it doesn't solve the problem. We need help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions