ngneat / until-destroy

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

Unable to find ɵcmp property in component using version 7.1.6 #83

Closed Gustav0ar closed 4 years ago

Gustav0ar commented 4 years ago

I'm trying to apply @UntilDestroy() to a component using Angular 9.1.2, but for some reason it is not finding ɵcmp property in my component. From what I read about it, it should be there with ivy. I'm using standard AOT compillation for debugging

I get this error:

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'onDestroy' of undefined
TypeError: Cannot read property 'onDestroy' of undefined
    at decorateDirective (ngneat-until-destroy.js:148)
    at ngneat-until-destroy.js:158
    at __decorate (tslib.es6.js:56)
    at Module../src/app/layout/admin/edit/admin-edit.component.ts (admin-edit.component.ts:26)
    at __webpack_require__ (bootstrap:84)
    at Module../src/app/layout/admin/edit/admin-edit.component.ngfactory.js (admin.module.ts:63)
    at __webpack_require__ (bootstrap:84)
    at Module../src/app/layout/admin/admin.module.ngfactory.js (admin-routing.module.ts:25)
    at __webpack_require__ (bootstrap:84)
    at ZoneDelegate.invoke (zone-evergreen.js:364)
    at Object.onInvoke (core.js:41720)
    at ZoneDelegate.invoke (zone-evergreen.js:363)
    at Zone.run (zone-evergreen.js:123)
    at zone-evergreen.js:857
    at ZoneDelegate.invokeTask (zone-evergreen.js:399)
    at resolvePromise (zone-evergreen.js:798) [angular]
    at resolvePromise (zone-evergreen.js:750) [angular]
    at polyfills.js:904:21 [angular]
    at Object.onInvokeTask (core.js:41698) [angular]
    at drainMicroTaskQueue (zone-evergreen.js:569) [<root>]
function getDef(type) {
    return (type[NG_COMPONENT_DEF] ||
        type[NG_DIRECTIVE_DEF]);
}

The function above returns undefined for me.

My component looks like this:

@UntilDestroy()
@Component({
  selector: 'app-admin-edit',
  templateUrl: './admin-edit.component.html',
  styleUrls: ['./admin-edit.component.scss'],
  animations: [
    stagger60ms,
    fadeInUp400ms,
  ],
})
export class AdminEditComponent implements OnInit {
...
}

I'm using tailwind css which required a custom webpack for loading postcss. That's the only difference my big project has from standard angular build...

arturovt commented 4 years ago

Provide a minimal reproducible example.

Gustav0ar commented 4 years ago

Provide a minimal reproducible example.

Sorry about that, I forgot to add, here it is: https://github.com/Gustav0ar/until-destroy-error

arturovt commented 4 years ago

Thanks for that. Will look ASAP.

arturovt commented 4 years ago

It doesn't work because you have enableIvy: false in tsconfig.app.json :slightly_smiling_face:

image

Gustav0ar commented 4 years ago

Yeah lol, my bad. Thanks for helping. Forgot to remove that when upgrading...