@@ -6,9 +6,9 @@ import { OperatorFunction, MonoTypeOperatorFunction } from '../types';
66import { pipe } from '../util/pipe' ;
77
88/* tslint:disable:max-line-length */
9+ export function reduce < T , R > ( accumulator : ( acc : R , value : T , index : number ) => R , seed : R ) : OperatorFunction < T , R > ;
910export function reduce < T > ( accumulator : ( acc : T , value : T , index : number ) => T , seed ?: T ) : MonoTypeOperatorFunction < T > ;
10- export function reduce < T > ( accumulator : ( acc : T [ ] , value : T , index : number ) => T [ ] , seed : T [ ] ) : OperatorFunction < T , T [ ] > ;
11- export function reduce < T , R > ( accumulator : ( acc : R , value : T , index : number ) => R , seed ?: R ) : OperatorFunction < T , R > ;
11+ export function reduce < T , R > ( accumulator : ( acc : R , value : T , index : number ) => R ) : OperatorFunction < T , R > ;
1212/* tslint:enable:max-line-length */
1313
1414/**
@@ -62,20 +62,20 @@ export function reduce<T, R>(accumulator: (acc: R, value: T, index: number) => R
6262 * @method reduce
6363 * @owner Observable
6464 */
65- export function reduce < T , R > ( accumulator : ( acc : R , value : T , index ?: number ) => R , seed ?: R ) : OperatorFunction < T , R > {
65+ export function reduce < T , R > ( accumulator : ( acc : T | R , value : T , index ?: number ) => T | R , seed ?: T | R ) : OperatorFunction < T , T | R > {
6666 // providing a seed of `undefined` *should* be valid and trigger
6767 // hasSeed! so don't use `seed !== undefined` checks!
6868 // For this reason, we have to check it here at the original call site
6969 // otherwise inside Operator/Subscriber we won't know if `undefined`
7070 // means they didn't provide anything or if they literally provided `undefined`
7171 if ( arguments . length >= 2 ) {
72- return function reduceOperatorFunctionWithSeed ( source : Observable < T > ) : Observable < R > {
72+ return function reduceOperatorFunctionWithSeed ( source : Observable < T > ) : Observable < T | R > {
7373 return pipe ( scan ( accumulator , seed ) , takeLast ( 1 ) , defaultIfEmpty ( seed ) ) ( source ) ;
7474 } ;
7575 }
76- return function reduceOperatorFunction ( source : Observable < T > ) : Observable < R > {
76+ return function reduceOperatorFunction ( source : Observable < T > ) : Observable < T | R > {
7777 return pipe (
78- scan ( ( acc : R , value : T , index : number ) : R => accumulator ( acc , value , index + 1 ) ) ,
78+ scan < T , T | R > ( ( acc , value , index ) => accumulator ( acc , value , index + 1 ) ) ,
7979 takeLast ( 1 ) ,
8080 ) ( source ) ;
8181 } ;
0 commit comments