masvis / angular4-hal

HAL for Angular
GNU General Public License v3.0
51 stars 52 forks source link

Errors when compiling in Angular 6. #23

Closed giard-alexandre closed 5 years ago

giard-alexandre commented 6 years ago

I'm getting some errors when compiling the project using Angular 6.0.5 and RxJS 6.2.1. I am using rxjs-compat as I get even more errors if I try to compile it without the compatibility shim. I don't know if I am missing something but I would appreciate some help! Thanks! Here is the error:

node_modules/angular4-hal/dist/src/rest.service.d.ts(28,40): error TS2314: Generic type 'ErrorObservable<T>' requires 1 type argument(s).
node_modules/angular4-hal/dist/src/rest.service.d.ts(29,47): error TS2314: Generic type 'ErrorObservable<T>' requires 1 type argument(s).
node_modules/angular4-hal/node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11): error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'.

PS: After some quick searching, it may be caused by the fact that you have 2 node_modules in the library.

dmarthaler commented 6 years ago

Same for me, using Angular 6.0.3 and RxJS 6.0.0 with compat installed.

ERROR in node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11): error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'.
node_modules/angular4-hal/dist/src/rest.service.d.ts(28,40): error TS2314: Generic type 'ErrorObservable<T>' requires 1 type argument(s).
node_modules/angular4-hal/dist/src/rest.service.d.ts(29,47): error TS2314: Generic type 'ErrorObservable<T>' requires 1 type argument(s).
node_modules/angular4-hal/node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11): error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'.
node_modules/angular4-hal/node_modules/rxjs/internal/symbol/observable.d.ts(4,18): error TS2687: All declarations of 'observable' must have identical modifiers.
hubciorz commented 6 years ago

Temporary fix:

  1. Remove ./node_modules/angular4-hal/dist
  2. Add (or extend) "include": ["../node_modules/angular4-hal/**/*.ts"] into tsconfig.app.json (or your tsconfig.json file)
  3. Add (or extend) "exclude": ["./node_modules/angular4-hal/**.spec.ts"] to the same file above

(point 3 is perhaps not needed since I don't see any unit tests)

sante85 commented 6 years ago

please make a pull request

hubciorz commented 6 years ago

@sante85 This does not fix the library. As I said, this is a temporary solution.

giard-alexandre commented 6 years ago

Am I correct in assuming that this error is caused due to the fact that the app's source code is being included with the compiled code?

hubciorz commented 6 years ago

@heuristicAL Yep, that might be true. The NPM package seems to be broken so in order to make it works you need to include either compiled lib + bindings or the source code (not both). I didn't really have much time to 100% investigate the reason why it got corrupted so I might be wrong, too.

giard-alexandre commented 6 years ago

@sante85 I'm not too sure if we can fix this issue using pull requests as we don't have access to the current build process for this lib. Seems to be a problem at build/packaging level, maybe caused by the fact that the source code and node_modules are included with the compiled output. It may be fixed by removing the source code and only including the compiled output.

cjansen18 commented 6 years ago

I created a pull request (first time I've ever done this!). When I build against my changes and copy them into the node_modules/angular4-hal/dist folder, my app has no further issues with Angular 6.

mpbalmeida commented 6 years ago

I created a fork of this project and published the build on npmjs and now everything works fine

https://github.com/mpbalmeida/hal-4-angular https://www.npmjs.com/package/hal-4-angular

You can use this build until the build process of this project is fixed.

kirsar commented 6 years ago

The fork worked even without rxjs-compat.

felixfiskare commented 6 years ago

Current (6.1.0) gives me

"ERROR in node_modules/angular4-hal/dist/src/rest.service.d.ts(28,40): error TS2314: Generic type 'ErrorObservable<T>' requires 1 type argument(s).
node_modules/angular4-hal/dist/src/rest.service.d.ts(29,47): error TS2314: Generic type 'ErrorObservable<T>' requires 1 type argument(s)."

fixed it by adding <any> after ErrorObservable on each line. Don't know what to change in source code though.

felixfiskare commented 6 years ago

@mpbalmeida can you give hints about what to change about the build process?

Or could you update your fork with the latest fixes from here?

mpbalmeida commented 6 years ago

@felixfiskare I just update the version 6.1.0, it should be ok. I run an automated build with circle-ci.

You can also post issues on my fork.

https://github.com/mpbalmeida/hal-4-angular/issues

cjansen18 commented 6 years ago

@felixfiskare -I also experienced the same issue:

"ERROR in node_modules/angular4-hal/dist/src/rest.service.d.ts(28,40): error TS2314: Generic type 'ErrorObservable' requires 1 type argument(s). node_modules/angular4-hal/dist/src/rest.service.d.ts(29,47): error TS2314: Generic type 'ErrorObservable' requires 1 type argument(s)."

Am working on an another pull request to hopefully resolve it. I'm also go attempt to make it Angular 6.1.1 compliant too.

mysteriousgirl7 commented 6 years ago

Hi , Iam getting this error ' error in library saying can’t convert type null/undefined to an object.' when Iam trying to display all the albums in the UI, Iam not able to figure this out, can someone please help.. Iam able to display one album in the ui but unable to display all the albums and get the below error

errorhal

allalbums

kirsar commented 6 years ago

Hi! Data provided by your API is not HATEOAS compatible. Library expects somethig like: image Try to put a break point in browser (Chrome?) in the beginning of the instantiateResourceCollection() and see what the payload parameter looks like.

mysteriousgirl7 commented 6 years ago

ok, i will try that . But I have set this up as my endpoint https://github.com/adrianmilne/spring-hateoas-demo , i think it should work..

mysteriousgirl7 commented 6 years ago

so I checked the format nd it looks correct,Iam not able to figure this out.. albums

mysteriousgirl7 commented 6 years ago

Can someone please help

kirsar commented 6 years ago

You have no "_embedded" and "_links" section in the top level collection itself. And the failing method expects '_embedded', see "for" loop in the beginning of the method. Unfortunately I can't help you with java spring end point, I'm on ASP.Core API.