Skip to content

Commit

Permalink
fix: give type args to higherOrder call in src/operator/publishReplay.ts
Browse files Browse the repository at this point in the history
operator/publishReplay delegates to operators/publishReplay. The call is
correct — *one* of the three overloads will be called, and it
doesn't matter which — 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
  • Loading branch information
sandersn committed Oct 24, 2017
1 parent 6dc1b80 commit 9f651b5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/operator/publishReplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ export function publishReplay<T, R>(this: Observable<T>, bufferSize?: number,
selectorOrScheduler?: IScheduler | OperatorFunction<T, R>,
scheduler?: IScheduler): Observable<R> | ConnectableObservable<R> {

return higherOrder(bufferSize, windowTime, selectorOrScheduler as any, scheduler)(this);
return higherOrder<T, R>(bufferSize, windowTime, selectorOrScheduler as any, scheduler)(this);
}

0 comments on commit 9f651b5

Please sign in to comment.