Skip to content

Commit 26bdc34

Browse files
committed
chore(first): add type guard overload
1 parent 36769b6 commit 26bdc34

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/internal/operators/first.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,29 @@ import { Observable } from '../Observable';
22
import { Operator } from '../Operator';
33
import { Subscriber } from '../Subscriber';
44
import { EmptyError } from '../util/EmptyError';
5-
import { MonoTypeOperatorFunction } from '../../internal/types';
5+
import { MonoTypeOperatorFunction, OperatorFunction } from '../../internal/types';
66
import { filter } from './filter';
77
import { take } from './take';
88
import { defaultIfEmpty } from './defaultIfEmpty';
99
import { throwIfEmpty } from './throwIfEmpty';
1010
import { identity } from '../util/identity';
1111

12+
/* tslint:disable:max-line-length */
13+
export function first<T>(): MonoTypeOperatorFunction<T>;
14+
export function first<T>(
15+
predicate: null | undefined,
16+
defaultValue: T
17+
): MonoTypeOperatorFunction<T>;
18+
export function first<T, S extends T>(
19+
predicate?: (value: T, index: number, source: Observable<T>) => value is S,
20+
defaultValue?: T
21+
): OperatorFunction<T, S>;
22+
export function first<T>(
23+
predicate?: (value: T, index: number, source: Observable<T>) => boolean,
24+
defaultValue?: T
25+
): MonoTypeOperatorFunction<T>;
26+
/* tslint:enable:max-line-length */
27+
1228
/**
1329
* Emits only the first value (or the first value that meets some condition)
1430
* emitted by the source Observable.

0 commit comments

Comments
 (0)