Skip to content
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

angular 9.0.0-rc.2 Cannot read property 'onDestroy' of undefined #42

Closed
leon opened this issue Nov 19, 2019 · 6 comments
Closed

angular 9.0.0-rc.2 Cannot read property 'onDestroy' of undefined #42

leon opened this issue Nov 19, 2019 · 6 comments

Comments

@leon
Copy link

leon commented Nov 19, 2019

I'm using nrwl NX and jest.
When I run jest I'm getting

TypeError: Cannot read property 'onDestroy' of undefined


node_modules/@ngneat/until-destroy/bundles/ng:/@ngneat/until-destroy/lib/until-destroy.ts:32:48
at Object.__decorate (../../../../node_modules/tslib/tslib.js:93:99)

Has anything changed in the latests RC's that could cause this to happen?

@leon
Copy link
Author

leon commented Nov 20, 2019

Update

I forked and updated until-destroy to the latest angular rc release, but the tests work, so it hasn't got anything to do with angular/core.

Nx uses the library jest-preset-angular and nx is currently using version 7.1.1

jest-preset-angular has released a version 8.0.0, but nx still hasn't updated to that version, so that might fix it.

The only thing i can think of is that jest-preset-angular doesn't compile to ivy code and thus ɵcmp will be null.

But I'm not sure how to get around it, or if I just have to wait for nx to catch up to angular 9. :(

@NetanelBasal
Copy link
Member

Hi, this is our peer dependencies requirements:

"peerDependencies": {
  "@angular/core": ">=9.0.0-next.10"
}

So I guess you'll have to wait or use the older version.

@0x6368656174
Copy link
Contributor

I have some issue when try run my app in storybook. I can't use old version, because i use Ivy.

@0x6368656174
Copy link
Contributor

This lib really useful, but we had to remove because of this bug.

@demike
Copy link

demike commented Mar 5, 2020

We have the same issue in storybook using Ivy

@akirpichnikov
Copy link

For some reason, Storybook doesn't use Angular Ivy with my setup and I had the same error. I added postinstall script with ngcc option to package.json according to the official docs and now everything works well.
After making these changes you may need to delete node_modules (rm -rf) and install them again.

P.S. to check if Ivy enabled you can import it from angular/core

import { Component, OnInit, ɵivyEnabled as ivyEnabled, OnDestroy } from '@angular/core';

ngOnInit(): void {
    console.log('ivyEnabled', ivyEnabled);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants