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

Compile error with typescript 2.4.1 #2701

Closed
cfarmerga opened this issue Jun 27, 2017 · 2 comments
Closed

Compile error with typescript 2.4.1 #2701

cfarmerga opened this issue Jun 27, 2017 · 2 comments

Comments

@cfarmerga
Copy link

With typescript 2.4.1, I get a compile error when trying to use rxjs 5.4.1 in my trivial angular 4 cli app during the webpack step. When I revert to typescript 2.3.3 using the same rxjs version, there is no error and rxjs features seem to work as expected.

ERROR in myapppath/node_modules/rxjs/Subject.d.ts (16,22): 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'. webpack: Failed to compile.

When I look at Observable.d.ts and Subject.d.ts, I see that it's true that the lift method is returning different types, even though Subject extends Observable here:

In Subject.d.ts:
lift<R>(operator: Operator<T, R>): Observable<T>;

In Observable.d.ts:
lift<R>(operator: Operator<T, R>): Observable<R>;

This blog post suggests stricter generic type checking on functions in 2.4, so I'm guessing the Subject.d.ts method sig might be a typo that was not noticed.
https://blogs.msdn.microsoft.com/typescript/2017/06/27/announcing-typescript-2-4/

RxJS version: 5.4.1

Code to reproduce:

Expected behavior:

Actual behavior:

Additional information:

@kwonoj
Copy link
Member

kwonoj commented Jun 27, 2017

dupe of #2699 , #2539, #2700 .

@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
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

2 participants