Skip to content

Commit 76d510f

Browse files
author
Harold Favereau
committed
make if truthy strictNullCheck compliant
1 parent f039a35 commit 76d510f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/operator/if-truthy.operator.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import { filter } from 'rxjs/operators';
2-
import { MonoTypeOperatorFunction, Observable } from 'rxjs';
1+
import {OperatorFunction} from 'rxjs';
2+
import {filter} from 'rxjs/operators';
33

44
/**
55
* filter !!value
66
*/
7-
export function ifTruthy<I>(): MonoTypeOperatorFunction<I> {
8-
return (source$: Observable<I>) => source$.pipe(
9-
filter((input: I) => !!input)
10-
);
7+
export function ifTruthy<I>(): OperatorFunction<NonNullable<I> | null | undefined, NonNullable<I>> {
8+
return filter((input: I | null | undefined): input is NonNullable<I> => !!input);
119
}

0 commit comments

Comments
 (0)