-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
New errors with RxJS on 2.4.1 #16593
Comments
CC @benlesh. This is actually a bug that's been caught. Check out https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#stricter-checking-for-generic-functions for details. |
@OliverJAsh There was a long debate about this in ReactiveX/rxjs#1234. It's always seemed to me like the bug is in rxjs, in that that override in Subject shouldn't be there in the first place. |
So since then the signature has been changed to this: lift<R>(operator: Operator<T, R>): Observable<T> I don't understand why back then it wasn't just lift<R>(operator: Operator<T, R>): Observable<R> and it looks like the compiler finds the current signature to be questionable as well. |
@DanielRosenwasser The problem is that they've been trying to use None of this makes sense from the type system perspective, because it only makes sense to define Alternatively, that entire method should be typed |
Thanks for the explanation @masaeedu! Couldn't this be solved by creating a |
I just saw this will be fixed for RxJS 6.0 thanks to ReactiveX/rxjs#2540 (@hearnden). |
Hi there, is the solution in the meantime to not go to Typescript 2.4? Thanks |
@AneelaBrister Typescript version 2.3.4 seems to continue to work. |
What's the workaround here? |
using typescript 2.3.4 or rxjs 6 alpha |
Using typescript 2.3.4 worked. rxjs 6 alpha gave an unmet peer dependency with angular/router |
I uninstalled typescript 2.4.1 and installed 2.3.4, it was resolved. |
|
I've used typescript 2.4.0 with rxjs 5.4.1 and that works fine. |
@floodedcodeboy I just tested typescript 2.4.1 and rxjs 5.4.1, to no avail:
Sounds like the only solution is to upgrade to rxjs 6 alpha. |
[email protected] and typescript 2.3.4 worked for me. |
@sflemingDCP This issue is specifically about using rxjs with TypeScript 2.4.x. |
@OliverJAsh incorrect ... if you had read my post correctly ... I referenced 2.4.0 ... not 2.4.1 - make sure your package.json file references 2.4.0 exactly - not ^2.4.0 or ~2.4.0 which will upgrade you to 2.4.1 ... I don't know why i bother really. it also makes the title of this ticket incorrect as TypeScript 2.4.0 works with rxjs 5.4.1 - however TypeScript 2.4.1 does not work with rxjs 5.4.1. If you want to use TypeScript 2.4.1 - then you will need to upgrade to rxjs 6 alpha ... I really hope you're not using that in production . :/ |
@floodedcodeboy You're correct. 2.4.0 works but 2.4.1 does not. I will update the issue title. Confusingly, the releases page lists 2.4.1 as "2.4": |
It isn't confusingly in as much as every minor release of TypeScript has followed that pattern for an extended period of time. Because of some internal challenges, from what I understand, |
Is it not be possible to simply override the type definition to ignore this error? Upgrading to an alpha release does not seem like an ideal fix, in particular because I am not sure that our current dependencies truly support that, Angular 4 in particular. Just hope that RxJS 6 will release soon-ish so libraries such as Angular can incorporate it as the supported version. In the case of Angular that would happen either in the next major release scheduled for September or at the worst case the major release after that, around March 2018. So I think not fixing this in another way could have a pretty tangible effect. |
As others have already pointed out, at least until this issue is fully resolved, being precise about which version of TypeScript and RxJS you specify is crucial for working around this issue, especially for Angular-CLI apps. The relevant entries in my package.json are shown below. Notice the absence of any ~ or ^ characters in the version number:
My app was generated using Angular-CLI 1.1.3 |
The issue in the RxJS repo: ReactiveX/rxjs#2539 |
Replaced typescript from ^2.4.1 to 2.4.0 worked for me |
Discussed here as well https://github.com/Microsoft/TypeScript/issues/16777 |
Thanks @floodedcodeboy . Your solution worked for me. |
Hey all, you can get around this using the |
Why not use an augmentation to resolve this temporarily without downgrading TypeScript or upgrading RxJS to an unstable version? The following works with [email protected] // augmentations.ts
// TODO: Remove this when RxJS releases a stable version with a correct declaration of `Subject`.
import {Operator} from 'rxjs/Operator';
import {Observable} from 'rxjs/Observable';
declare module 'rxjs/Subject' {
interface Subject<T> {
lift<R>(operator: Operator<T, R>): Observable<R>;
}
} |
@claudiuconstantin im having thes same issue. still getting error TS2415 for Subject and WebSocketSubject with typescript 2.4.1 even after updating rxjs to 6.0.0-alpha.0 edit: may be a result of unmet peer dependencies? |
microsoft/TypeScript#16593 Work in progress (webpack isn't happy) and @sstone has an alternative fix anyway Signed-off-by: James Taylor <[email protected]>
Unmet peer dependency errors in this instance just means that those angular dependencies require RxJS 5.0.1 or higher, but below 6. Angular could still work with RxJS higher than they have specified, as they often work with higher versions of TypeScript. But I think you're always at risk of some part of Angular not working or an arbitrary patch or minor version update breaking your build. So use the solution proposed by @aluanhaddad instead, unless you for some other reason want to use the next version of RxJS already. |
@aluanhaddad, nice work, all good if you directly use |
@claudiuconstantin If another dependency directly depends on it, i.e. not just a peer dependency, you have RxJS in your project the same way you have it if you depended on it directly. So the augmentation should work just as well. |
fyi the fix already landed on RxJS 5.4.2 (changelog), you can either close this issue or leave it open. Bumping RxjS to v5.4.2 fixed it in both TypeScript and Angular in my case, and I no longer need this |
@DanielRosenwasser @OliverJAsh FYI: This was resolved with the release of rxjs 5.4.2, and this issue can be closed. All: rxjs 5.4.2 resolves this issue.Either way, this issue can be closed as it was a bug in rxjs, not TypeScript. |
When using the TS 2.4.1 and RxJS 5.4.1 (latest), I get a new error that I didn't have before upgrading to using TS 2.4.1.
You may already be aware of this—it is an insiders build after all—but thought I should point it out just in case.
The text was updated successfully, but these errors were encountered: