angelnikolov / ts-cacheable

Observable/Promise Cache Decorator
https://npmjs.com/package/ts-cacheable
ISC License
340 stars 42 forks source link

'Cacheable' is not initialized at ngx-cacheable\dist\cacheable.decorator.ts #25

Closed rafaelfgx closed 5 years ago

rafaelfgx commented 5 years ago

Hello!

First I want to thank you for the great work!

I am having the following error in the latest versions (1.1.0, 1.1.1, 1.1.2, 1.1.3) when running ng serve:

Only initialized variables and constants can be referenced in decorators because the value of this variable is needed by the template compiler in 'Cacheable' 'Cacheable' references 'Cacheable' 'Cacheable' is not initialized at ngx-cacheable\dist\cacheable.decorator.ts(4,22).

If I change to version 1.0.9, it works normally.

I'm using node 11.12.0 and Angular CLI 7.3.6.

Thank you for you attention.

image

image

angelnikolov commented 5 years ago

Hm, will try it out and get back to you with a solution. In the meantime it will be really helpful if you create a stackblitz where this is reproducible :) Also, can you show me the template of this component? I just updated one of my test projects to your version of the CLI and node and I still can't reproduce the issue :(

angelnikolov commented 5 years ago

I will take a look tomorrow. Thanks for the info!

rafaelfgx commented 5 years ago

Thank you for your time!

I created a test app:

https://stackblitz.com/edit/angular-ngx-cacheable

The app works online, but if download and run local, the error occurs.

Steps to reproduce:

1) Download the app.

2) Run npm i.

3) Run ng serve.

image

nico13051995 commented 5 years ago

I have the same issue, but only with AOT, version 1.0.9 works great.

angelnikolov commented 5 years ago

I think it has something to do with the new function expressions I added as part of the refactor, as mentioned here https://angular.io/guide/aot-compiler#metadata-restrictions Will try to resolve those asap. Thanks guys!

angelnikolov commented 5 years ago

Fixed in https://github.com/angelnikolov/ngx-cacheable/commit/43aa04d8a66a933f3d42aceaf3eaaa2908bbce9a