How do I enable private methods?
See original GitHub issueI’m surprised they aren’t enabled by default? because ember-cli-babel has them 🙃
but anywho, I have this error in C.I.: https://github.com/NullVoxPopuli/ember-array-map-resource/pull/103/checks?check_run_id=3702630696#step:5:215
- originalErrorMessage: /home/runner/work/ember-array-map-resource/ember-array-map-resource/-private/resources/array-map.ts: Class private methods are not enabled.
20 |
21 | // @private
> 22 | get #records(): Element[] {
| ^
23 | return this.args.positional[0];
24 | }
25 |
- stack: SyntaxError: /home/runner/work/ember-array-map-resource/ember-array-map-resource/-private/resources/array-map.ts: Class private methods are not enabled.
Classic build works just fine with private fields: https://github.com/NullVoxPopuli/ember-array-map-resource/pull/103/checks?check_run_id=3702630588
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
babel/plugin-proposal-private-methods
When true, private methods will be assigned directly on its parent via Object.defineProperty rather than a WeakSet . This results in improved performance ......
Read more >Private class features - JavaScript - MDN Web Docs - Mozilla
Class fields are public by default, but private class members can be created by using a hash # prefix. The privacy encapsulation of...
Read more >How to Enable Private Method Syntax Proposal in React App?
You can use the @babel/plugin-proposal-class-properties. Install with npm install --save-dev @babel/plugin-proposal-class-properties.
Read more >Class private methods are not enabled. #419 - GitHub
When I run ember s I see the error described Class private methods are not enabled . Do we just need to wait...
Read more >Babel 7.14 enables class fields & private methods by default ...
Babel 7.14 enables class fields & private methods by default in @babel/preset-env ... Babel is a free and open-source JavaScript transcompiler. It ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe this is the same thing I described in https://github.com/babel/ember-cli-babel/issues/419#issuecomment-971787156, since we use ember-cli-babel for compilation still we’re going to have the same issue.
Been running into this as well. Discovered
@embroider/webpack
depends on the old pre-release version of babel’s preset env.babel-preset-env
has been deprecated in favor of@babel/preset-env
. Looks like the new versions useplugin-proposal-private-methods
: https://github.com/babel/babel/blob/87fc2e76d77b0bc78b76cced469bd64c5edf141f/packages/babel-preset-env/package.json#L37 But the pre-release package doesn’t: https://github.com/babel/babel-preset-env/blob/31f33e3656e1bd8036317c54128fdc2812a2e8aa/package.json#L24So I believe the solution is to migrate from
babel-preset-env
to@babel/preset-env