sureshchahal / angular2-adal

Angular 2 wrapper for adal.js
MIT License
41 stars 50 forks source link

Typescript >= 2.4.1 gives Type 'Observable<void>' is not assignable to type 'Observable<User>' #64

Closed nelsonmorais closed 7 years ago

nelsonmorais commented 7 years ago

Hi,

After updating from Typescript 2.3.x to 2.4.1 or higher I started to get the error Type 'Observable' is not assignable to type 'Observable' at node_modules/ng2-adal/ts/services/adal.service.ts:135:9

This happens because Typescript does a better check on generic types since 2.4.1

Possible fix would be to change: https://github.com/sureshchahal/angular2-adal/blob/75dcf0f1a5307256c9dd3c58c8deb666a2402650/src/services/adal.service.ts#L129

to: return Observable.bindCallback\<User>>((cb: (u: adal.User) => User) => {

I also tried to set the settings below on tsconfig.json but none of them worked for me although they were mentioned as workarounds for similar problems in other libraries until they were fixed: "skipLibCheck": true, "skipDefaultLibCheck": true, "noStrictGenericChecks": true,

Alternative is to stick with TS 2.3.x but that would not be the best solution for the problem.

Created the PR https://github.com/sureshchahal/angular2-adal/pull/65 with the fix.

Note: Using npm version 1.0.1 of this package

nelsonmorais commented 7 years ago

PR #65 Merged. Closing issue.