Skip to content

Commit

Permalink
chore(last): add type guard overload
Browse files Browse the repository at this point in the history
Closes #3717
  • Loading branch information
cartant committed Jul 8, 2018
1 parent 26bdc34 commit dc9d4d6
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/internal/operators/last.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,29 @@ import { Observable } from '../Observable';
import { Operator } from '../Operator';
import { Subscriber } from '../Subscriber';
import { EmptyError } from '../util/EmptyError';
import { MonoTypeOperatorFunction } from '../../internal/types';
import { MonoTypeOperatorFunction, OperatorFunction } from '../../internal/types';
import { filter } from './filter';
import { takeLast } from './takeLast';
import { throwIfEmpty } from './throwIfEmpty';
import { defaultIfEmpty } from './defaultIfEmpty';
import { identity } from '../util/identity';

/* tslint:disable:max-line-length */
export function last<T>(): MonoTypeOperatorFunction<T>;
export function last<T>(
predicate: null | undefined,
defaultValue: T
): MonoTypeOperatorFunction<T>;
export function last<T, S extends T>(
predicate?: (value: T, index: number, source: Observable<T>) => value is S,
defaultValue?: T
): OperatorFunction<T, S>;
export function last<T>(
predicate?: (value: T, index: number, source: Observable<T>) => boolean,
defaultValue?: T
): MonoTypeOperatorFunction<T>;
/* tslint:enable:max-line-length */

/**
* Returns an Observable that emits only the last item emitted by the source Observable.
* It optionally takes a predicate function as a parameter, in which case, rather than emitting
Expand Down

0 comments on commit dc9d4d6

Please sign in to comment.