ngneat / until-destroy

🦊 RxJS operator that unsubscribe from observables on destroy
https://netbasal.com/
MIT License
1.74k stars 100 forks source link

Angular 11 compatibility: Dependency injection error using until-destroy #140

Closed lujakob closed 3 years ago

lujakob commented 3 years ago

After upgrading to Angular 11 I get the following error if I navigate to a lazy loaded module that has a component using until-destroy in it's declarations. The component itself is not loaded yet. Having it in the module declarations is already enough for the following JS error:

ERROR Error: Uncaught (in promise): ReferenceError: ConfirmDialogService is not defined
ReferenceError: ConfirmDialogService is not defined
    at Module.BkYQ (card-order-overview.component.ts:19)

card-order-overview.component.ts is the component using until-destroy class decorator. "ConfirmDialogService" is the first service in the constructor. I have four services in the constructor, and the one I state first is the one that appears in the error. So it doesn't matter which one is first.

This was working already in the version before. I'm 100% sure if I updated from version 10 or from 9 to 10 to 11. So I can't tell if the last working version was Angular 9 or 10.

arturovt commented 3 years ago

Hey @lujakob

This is an issue in Angular CLI, this issue has been received in many packages. There is a fix for this https://github.com/angular/angular-cli/pull/19841 that was merged day ago.

lujakob commented 3 years ago

@arturovt your solution works. I removed "emitDecoratorMetadata": true, from tsconfig.json.

arturovt commented 3 years ago

@lujakob

P.S. try to use the latest version, it's 11.1. I've just upgraded the project to 11.1 (https://github.com/ngneat/until-destroy/pull/141), you can see that all tests have been passed (w/o touching tsconfig.json).