-
Notifications
You must be signed in to change notification settings - Fork 3k
from() does not infer type correctly with TS 3.6 #4992
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
Comments
FWIW, I think the problem is that a function asObservable(input: string | Promise<string>): Observable<string> {
return typeof input === "string" ? of(input) : from(input);
} What it is in TypeScript 3.6, that has effected this changed behaviour, IDK. |
That is the reason we wrote the type switch in that helper, but still you'd expect |
Hard to see this as anything other than a TypeScript bug: declare const i: ObservableInput<string>;
const r = from(i); // Observable<unknown> And one that will pretty badly wreck the typings that will be even more widely used in v7. 😭 |
@benlesh ^ |
Yeah already filed in microsoft/TypeScript#33131 But is there a need to use |
I think there might be, yes: |
Yes, specifically this doesn't work without it: // from(Observable<A> | Observable<B>): Observable<A | B>
from(Math.random() > 0.5 ? of('123') : of(123)); |
This seems to be fixed in TypeScript 3.6.3. |
Yep, can confirm it’s fixed. |
Uh oh!
There was an error while loading. Please reload this page.
Bug Report
Current Behavior
Reproduction
Expected behavior
Should compile
Environment
Possible Solution
Instead of using
ObservedValueOf<T>
:declare
from
like:this seems to work.
Additional context/Screenshots

The text was updated successfully, but these errors were encountered: