Skip to content

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

@jordimarimon

Description

@jordimarimon

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

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions