Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Angular Non AOT compiler doesn't emit class decorators in specific cases#39574

Copy link
Copy link
@ratoaq2

Description

@ratoaq2
Issue body actions

馃悶 bug report

Affected Package

Angular Non AOT compiler (Jit Mode)

Is this a regression?

Yes, the very same scenario works on Angular 8.x

Description

Given that AOT is disabled ("aot": false in angular.json)
Given a class that is responsible of configuring "class decorators", if I decorate a regular typescript class with a decorator generated by that class, the compiled javascript doesn't emit the class decorator properly.

class DecoratorBuilder {
  customClassDecorator<T extends { new (...args: any[]): {} }>(constructor: T) {
    console.log('Class Decorated');
    return class extends constructor {
      myName = 'Decorated Foobar';
    };
  }
}

export function ClassDecorators() {
  return new DecoratorBuilder();
}

@ClassDecorators().customClassDecorator
class MyNonAngularClass {
  myName = 'foobar';
}

馃敩 Minimal Reproduction

https://github.com/ratoaq2/angular-non-aot-class-decorator

Just start the app:
npm install
npm start

access http://localhost:4200
You should see: Hello Decorated Foobar!
But you see: Hello foobar!

If you enable "aot": true, it works correctly. But that's not an option because I also face this issue in my spec tests where I can't enable aot.

馃敟 Exception or Error

No exception or error

馃實 Your Environment

Angular Version:


Angular CLI: 10.0.8
Node: 12.18.4
OS: win32 x64

Angular: 10.0.14
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: No

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1000.8
@angular-devkit/build-angular     0.1000.8
@angular-devkit/build-optimizer   0.1000.8
@angular-devkit/build-webpack     0.1000.8
@angular-devkit/core              10.0.8
@angular-devkit/schematics        10.0.8
@angular/cli                      10.0.8
@ngtools/webpack                  10.0.8
@schematics/angular               10.0.8
@schematics/update                0.1000.8
rxjs                              6.5.5
typescript                        3.9.7
webpack                           4.43.0

Anything else relevant?
It doesn't seem to be a typescript issue

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilerstate: has PR

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.