-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Code is running ok, but typing is failing #4119
Comments
Hmm, I'm still trying to learn RxJS internals I could be wrong about any of this, but here's what I've found with a little poking around: Firstly the specific type error that you get on stackblitz seems to be something to with stackblitz's TS version, or with the way the current version of the stackblitz editor deals with TS, or with the way stackblitz interacts with rxjs imports (more on that below). If I copy the same code into native VS Code, then I get a different TS error, both in VS Code itself and when I run tsc, because that code legitimately doesn't type check. However, the issue is the partition, not the switchMap. Locally, I get this as an error on line 12:
This one makes sense, because partition returns a UnaryFunction, not an OperatorFunction, and pipe only takes OperatorFunctions as arguments. It seems like partition was broken (at least when used in pipe) with the move to pipeable operators, but the clean up work to deprecate/replace it hasn't been priority as partition isn't that widely used. See these issues: As for the stackblitz error, I tried changing the TS version I had locally to a bunch of different versions from 2.6 to latest stable (3.0) and I couldn't repro the error from stackblitz with your code, so I think it's the imports thing... Here's your code with the rxjs dependency version changed to 5.5.12: https://stackblitz.com/edit/typescript-xidamf This is a (sort of) educated guess, but I think that because of the way imports work in rxjs 6 and the way stackblitz gets dependencies, stackblitz is seeing of and switchMap as coming from two different libs, and therefore seeing the Observable classes they rely on as two separately defined classes, which means that private and protected members will be incompatible (because they didn't come from the same declaration), despite them being identical in practice. So I guess this can be closed as the issue with your code is not a bug, but it might be worth someone looking into the stackblitz thing? Unless I'm missing some obvious fix/workaround for it.
From a quick look, I couldn't see anything specifically for this on the stackblitz side, but I did see this, which could well be related (and seems to still be an issue): stackblitz/core#477 |
Thank you very much!! @jgbpercy, you clarified a lot of things to me 😄 Then, if partition operator is broken and it's a stackblitz issue too, should we close this issue? |
Ok, thank you 👍 |
Bug Report
Current Behavior
Code is running like I expected, but typing is failing and I don't understand why.
Reproduction
Expected behavior
typing should not error
Environment
Possible Solution
Additional context/Screenshots
The text was updated successfully, but these errors were encountered: