Skip to content

Runtime (#) private fields for methods throw compilation error #24426

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

Closed
flevi29 opened this issue Dec 13, 2022 · 3 comments
Closed

Runtime (#) private fields for methods throw compilation error #24426

flevi29 opened this issue Dec 13, 2022 · 3 comments

Comments

@flevi29
Copy link

flevi29 commented Dec 13, 2022

Which @angular/* package(s) are the source of the bug?

compiler

Is this a regression?

Yes

Description

When building an angular app with a class containing runtime JavaScript private methods on Angular 15.0.3, Babel starts complaining about these private methods needing a plugin. 15.0.2 did not have this problem.

Please provide a link to a minimal reproduction of the bug

https://github.com/flevi29/angular_private_method

Please provide the exception or error you saw

./src/app/app.component.ts - Error: Module build failed (from ./node_modules/.pnpm/@[email protected]_rkbkeouzdriyhxsgalx5dhmej4/node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js):
SyntaxError: C:\-\angular_private_method\src\app\app.component.ts: Class private methods are not enabled. Please add `@babel/plugin-proposal-private-methods` to your configuration.
   5 |     }
   6 |     #title;
>  7 |     #somePrivateMethod() {
     |     ^
   8 |         console.log('`title` has been called');
   9 |     }
  10 |     get title() {

Please provide the environment you discovered this bug in (run ng version)

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 15.0.3
Node: 18.12.1
Package Manager: pnpm 7.18.1
OS: win32 x64

Angular: 15.0.3
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1500.3
@angular-devkit/build-angular   15.0.3
@angular-devkit/core            15.0.3
@angular-devkit/schematics      15.0.3
@schematics/angular             15.0.3
rxjs                            7.6.0
typescript                      4.8.4

Anything else?

Is using runtime private methods wherever we can and it makes sense to do so a good practice? Every browser except the one that should be thrown into a pit of flames supports runtime private methods at this point.

@alan-agius4 alan-agius4 transferred this issue from angular/angular Dec 13, 2022
@alan-agius4
Copy link
Collaborator

Duplicate of #24411

@alan-agius4 alan-agius4 marked this as a duplicate of #24411 Dec 13, 2022
@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2022
@flevi29
Copy link
Author

flevi29 commented Dec 13, 2022

Whoops, didn't check closed issues, sorry.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants