Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Compilation fails with TypeScript 2.4 #1487

Open
evmar opened this issue Jun 15, 2017 · 19 comments
Open

Compilation fails with TypeScript 2.4 #1487

evmar opened this issue Jun 15, 2017 · 19 comments

Comments

@evmar
Copy link

evmar commented Jun 15, 2017

95         return new PromiseObservable<T>(ish, scheduler);
                                           ~~~

third_party/javascriptnode_modules/rxjs/v5_2_0/src/observable/FromObservable.ts(95,41): error TS2345: Argument of type '(Subscribable<T> & Promise<{}>) | (PromiseLike<T> & Promise<{}>) | (ArrayLike<T> & Promise<{}>)' is not assignable to parameter of type 'Promise<T>'.
  Type 'Subscribable<T> & Promise<{}>' is not assignable to type 'Promise<T>'.
    Types of property 'then' are incompatible.
      Type '<TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1 | PromiseLike<TResult1>, ...' is not assignable to type '<TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, on...'.
        Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
          Types of parameters 'value' and 'value' are incompatible.
            Type '{}' is not assignable to type 'T'.
70   return (operator.caught = caught);
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

third_party/javascript/node_modules/rxjs/v5_2_0/src/operator/catch.ts(70,3): error TS2322: Type 'Observable<{}>' is not assignable to type 'Observable<R>'.
  Type '{}' is not assignable to type 'R'.
70   return (operator.caught = caught);
             ~~~~~~~~~~~~~~~

third_party/javascript/node_modules/rxjs/v5_2_0/src/operator/catch.ts(70,11): error TS2322: Type 'Observable<{}>' is not assignable to type 'Observable<T>'.
  Type '{}' is not assignable to type 'T'.
41   return this.lift(new DefaultIfEmptyOperator(defaultValue));
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

third_party/javascript/node_modules/rxjs/v5_2_0/src/operator/defaultIfEmpty.ts(41,3): error TS2322: Type 'Observable<{} | R>' is not assignable to type 'Observable<T | R>'.
  Type '{} | R' is not assignable to type 'T | R'.
    Type '{}' is not assignable to type 'T | R'.
      Type '{}' is not assignable to type 'R'.
@benlesh
Copy link
Contributor

benlesh commented Jun 19, 2017

cc @david-driscoll

@benlesh
Copy link
Contributor

benlesh commented Jun 19, 2017

@evmar you should try 6.0.0-alpha.0, it targets TS 2.3. (in the next branch)

@Igorbek
Copy link
Contributor

Igorbek commented Jun 19, 2017

isn't this rxjs 4 repo?

@david-driscoll
Copy link
Contributor

Sounds like it's related to https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#typescript-24 without digging into it much.

This appears to be revealing a few issues like not giving the full type DefaultIfEmptyOperator and a few other bits. That said using rxjs as a library shouldn't have a big impact if you're using it as a module, not compiling it as a third party.

@DanielRosenwasser
Copy link
Contributor

Also related to the 2.4 changes is microsoft/TypeScript#16593.

@amcdnl
Copy link

amcdnl commented Jun 27, 2017

I'm getting these on 2.4.1 now:

[at-loader] ./node_modules/rxjs/Subject.d.ts:16:22
    TS2415: Class 'Subject<T>' incorrectly extends base class 'Observable<T>'.
  Types of property 'lift' are incompatible.
    Type '<R>(operator: Operator<T, R>) => Observable<T>' is not assignable to type '<R>(operator: Operator<T, R>) => Observable<R>'.
      Type 'Observable<T>' is not assignable to type 'Observable<R>'.
        Type 'T' is not assignable to type 'R'.

[at-loader] ./node_modules/rxjs/observable/dom/WebSocketSubject.d.ts:24:22
    TS2415: Class 'WebSocketSubject<T>' incorrectly extends base class 'AnonymousSubject<T>'.
  Types of property 'lift' are incompatible.
    Type '<R>(operator: Operator<T, R>) => WebSocketSubject<R>' is not assignable to type '<R>(operator: Operator<T, R>) => Observable<T>'.
      Type 'WebSocketSubject<R>' is not assignable to type 'Observable<T>'.
        Types of property 'operator' are incompatible.
          Type 'Operator<any, R>' is not assignable to type 'Operator<any, T>'.
            Type 'R' is not assignable to type 'T'.

@benlesh - is the recommended solution to not upgrade at this point?

@paulpdaniels
Copy link
Contributor

@evmar @amcdnl @benlesh should this be moved over to ReactiveX/rxjs? I think having this here is going to be confusing for incoming readers.

@benlesh
Copy link
Contributor

benlesh commented Jun 27, 2017

Yes.

@joechlanda
Copy link

Ran into the same issue just now, downgrading typescript for now resolve the compilation error. Glad I came across this issue 👍

@paulpdaniels
Copy link
Contributor

@evmar or @mattpodwysocki do you mind closing?

@evmar
Copy link
Author

evmar commented Jun 27, 2017

Sorry, I lack context. Is the issue fixed?

@DanielRosenwasser
Copy link
Contributor

DanielRosenwasser commented Jun 27, 2017

My understanding is that the issue will be fixed in RxJS 6.0. The signature hasn't been corrected in 5.x.

@RobAltena RobAltena mentioned this issue Jun 28, 2017
@paulpdaniels
Copy link
Contributor

This issue is not related to this repository. RxJS 5 and later is a different repository. See my link earlier, I'm trying to minimize people coming here and expecting to get help on a repo that is in maintenance mode.

@claudiuconstantin
Copy link

I'm confused about the whole ReactiveX/rxjs vs Reactive-Extensions/RxJS thing. Better descriptions for the two repositories would be very helpful.

@benlesh
Copy link
Contributor

benlesh commented Jul 18, 2017

@claudiuconstantin There are now warnings/notices all over the RxJS 4 readme and docs (reactive-extensions)

Everyone else: This issue has been solved by RxJS 5.4.2

@raysuelzer
Copy link

I do not see that it is resolved at all. Observable and Subject are still not assignable.
Type 'Observable' is not assignable to type 'AsyncSubject'.

@benlesh
Copy link
Contributor

benlesh commented Oct 30, 2017

@mattpodwysocki can you please close this, as we're in the wrong repo lol

@raysuelzer ... you've got a classic typed-language problem there... AsyncSubject inherits from Observable, not the other way around. So you can't pass an Observable where AsyncSubject is expected.

@yamidvo
Copy link

yamidvo commented Nov 30, 2017

I have an error in switchMap operator:

export class AvailableStoreTypesLoadedEffect {
constructor(private actions$: Actions,
          private service: AvailableService) {

}

 @Effect()
 AvailableStoreTypesLoadedEffect$ = this.actions$
 .ofType(FETCH_AVAILABLE_STORE_TYPES)
 .pipe(
   switchMap(action => this.service.fetchAvailableStoreTypes()),//Error:(22, 9) TS2684:The 'this' context of type 'void' is not assignable to method's 'this' of type 'Observable<{}>'.
   map(res => new AvailableStoreTypesLoaded(res))
  );
}

I tried with:

Observable.of({})
  .pipe(
    switchMap(() => Observable.of({}))//Error:(22, 9) TS2684:The 'this' context of type 'void' is not assignable to method's 'this' of type 'Observable<{}>'.
  );

but I get the same error.

My environment is:

angular 5.0.3
typescript 2.4.2
rxjs 5.5.2

@paulpdaniels
Copy link
Contributor

@yamidvo Please see the above conversation. This repo does not support RxJS 5 and above.

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

No branches or pull requests