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

Class 'Subject<T>' incorrectly extends base class 'Observable<T>' with TypeScript 2.4 #2705

Closed
zoltantarcsay opened this issue Jun 28, 2017 · 14 comments

Comments

@zoltantarcsay
Copy link

zoltantarcsay commented Jun 28, 2017

RxJS version:
5.4.1

Code to reproduce:
Save this line this to a TypeScript file (test.ts):
import {Subject} from 'rxjs/Subject';
Then compile:
tsc test.ts

Expected behavior:
No errors

Actual behavior:
Compilation error:

node_modules/rxjs/Subject.d.ts(16,22): error 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'.

Additional information:
TypeScript version: 2.4.1

TypeScript 2.4 introduced stricter checks for generics (see this blog post)

(Looks like this could be a typo in Observable#lift)

@kwonoj
Copy link
Member

kwonoj commented Jun 28, 2017

dupe of #2699 , #2539, #2700 . #2701 #2702 #2703 #2704

@grafox
Copy link

grafox commented Aug 7, 2017

update TS. That's it

@ws6
Copy link

ws6 commented Aug 7, 2017

upgrade ts won't help. according to ts webpage, I added --noStrictGenericChecks to suppress the error message.

tsc --noStrictGenericChecks

@Argon2000
Copy link

Got this error WHEN i updated to TS 2.4.2

@Argon2000
Copy link

Fixed by updating RxJS to 5.4.2

@micaz
Copy link

micaz commented Aug 10, 2017

@Argon2000
It Work for me, Thank You

@am0wa
Copy link

am0wa commented Aug 10, 2017

Didn't work for me with typescript 2.4.2 & RxJS 5.4.2
Started to work after the downgrading the typescript to 2.4.0

@am0wa
Copy link

am0wa commented Aug 11, 2017

@dearfog TypeScript to 2.4.0

@maximilian02
Copy link

I've deleted Rxjs node_module folder, and ran again npm install. That made the magic.

@theBull
Copy link

theBull commented Aug 12, 2017

@AndrewMur I don't believe there is a Typescript version 5.4.0, latest version (as of right now) is 2.4.2 - perhaps you got it confused with the latest version of RxJS which is currently 5.4.3?

@am0wa
Copy link

am0wa commented Aug 14, 2017

@theBull srry for typo & confuse. Yeap I meant downgrade to typescript 2.4.0

@tramel-woodard
Copy link

Anyone installing from a package.json file, try changing your typescript devDependency from:
"typescript": "^2.0.3" to "typescript": "2.4.0" specifically.

Then delete the typescript package from your node_modules folder and then retry npm install.

@kwonoj
Copy link
Member

kwonoj commented Aug 14, 2017

I am seeing incorrect information's shared in this issue's comment - anyone still experiences compilation issue with LATEST RxJS, please confirm

  1. if there are any other copy of RxJS v5 stays under node_modules which isn't latest, should be checked by physical lookup
  2. if above is not case and compilation fail occurred with strict generic check on 2.4.2, confirm any user code inherits have correct type definition of base classes.

(check detail at #2726 (comment))

RxJS itself has fixed its own issue of library regarding this type definition issue and remaining failure mostly shoud be those cases listed above. If you're certain library has still failing, please don't hesitate to create new issue with repo have smallest code can reproduce issue.

I'm locking this issue itself to avoid further confusions.

@ReactiveX ReactiveX locked and limited conversation to collaborators Aug 14, 2017
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

11 participants