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

rxjs fails to compile on Typescript 2.6 #2991

Closed
sandersn opened this issue Oct 24, 2017 · 1 comment
Closed

rxjs fails to compile on Typescript 2.6 #2991

sandersn opened this issue Oct 24, 2017 · 1 comment

Comments

@sandersn
Copy link
Contributor

In src/operator/publishReplay.ts, the delegating call to higherOrder (which is an alias for publishReplay in src/operators/publishReplay.ts), has arguments that don't provide enough information to infer type arguments. That's because the third argument is cast to any, which is because it's just a delegation; a call to publishReplay could delegate to any of the three overloads of higherOrder. The compiler has to choose one, however, and it chooses the wrong one in Typescript 2.6.

RxJS version:
master

Code to reproduce:
Update typescript to typescript@next then try to npm run build_all

Expected behavior:
No compile error

Actual behavior:
Type Observable<{}> is not assignable to type Observable<R> | ConnectableObservable<R>

sandersn added a commit to sandersn/rxjs that referenced this issue Oct 24, 2017
operator/publishReplay delegates to operators/publishReplay. The call is
correct &mdash; *one* of the three overloads will be called, and it
doesn't matter which &mdash; but
the compiler has to choose one overload. Previously, the call didn't
include type arguments, and the type of the one argument that would be
used for inference, selectorOrScheduler, was of type `any`. So the
compiler chose the first overload with four parameters. However, the
return type of this overload is incorrect, whereas the return type of the
third overload is correct. Provide the type
arguments explicitly so that the last, most general overload gets called. This
results in the the correct return type, `OperatorFunction<T, R>`.

Closes ReactiveX#2991
@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

1 participant