Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unable to use JS decorators in private methods with the development build #61228

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

Open
1 task done
jordimarimon opened this issue Apr 22, 2025 · 1 comment · May be fixed by #61227
Open
1 task done

Unable to use JS decorators in private methods with the development build #61228

jordimarimon opened this issue Apr 22, 2025 · 1 comment · May be fixed by #61227
Labels
area: compiler Issues related to `ngc`, Angular's template compiler freq1: low state: has PR type: bug/fix
Milestone

Comments

@jordimarimon
Copy link

jordimarimon commented Apr 22, 2025

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

19.2.6

Description

When building with the default development configuration, if one is using JS decorators in a private method (not the experimental ones from TypeScript, experimentalDecorators: false) gets the following error:

Image

If the method is public, the error doesn't happen.

This error doesn't happen in version 19.2.6.

Minimal Reproduction

Reproduction url: https://github.com/jordimarimon/angular-cli-js-decorator

The application has been created using the following command:

npx @angular/cli new test-app --experimental-zoneless --inline-style --inline-template --minimal --skip-git --skip-install --skip-tests --standalone --strict

There are only two additional files:

  • src/app/app.service.ts
  • src/app/debounce.ts

Run the command npx ng build --configuration=production and there shouldn't be any error.

Now run the command npx ng build --configuration=development and there should be an error.

If you downgrade to version 19.2.6 both commands run without any error.

Exception or Error

✘ [ERROR] Expected identifier but found "#foo"

    src/app/app.service.ts:31:20:
      31 │     }], () => [], { #foo: [] }); })();
         ╵                     ~~~~

Your Environment

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


Angular CLI: 19.2.8
Node: 22.12.0
Package Manager: npm 11.3.0
OS: linux x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.8
@angular-devkit/build-angular   19.2.8
@angular-devkit/core            19.2.8
@angular-devkit/schematics      19.2.8
@angular/cli                    19.2.8
@schematics/angular             19.2.8
rxjs                            7.8.2
typescript                      5.7.3
zone.js                         0.15.0

Anything else relevant?

No response

@alan-agius4
Copy link
Contributor

This seem a regression caused by angular/angular-cli@6f913ad

@clydin clydin transferred this issue from angular/angular-cli May 8, 2025
@clydin clydin added the area: compiler Issues related to `ngc`, Angular's template compiler label May 8, 2025
@ngbot ngbot bot added this to the needsTriage milestone May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: compiler Issues related to `ngc`, Angular's template compiler freq1: low state: has PR type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants