diff --git a/api_guard/dist/types/operators/index.d.ts b/api_guard/dist/types/operators/index.d.ts index 3a85ca4d31..6ca630b1b1 100644 --- a/api_guard/dist/types/operators/index.d.ts +++ b/api_guard/dist/types/operators/index.d.ts @@ -110,7 +110,6 @@ export declare function exhaustMap(project: (value: T, index: number) = export declare function expand(project: (value: T, index: number) => ObservableInput, concurrent?: number, scheduler?: SchedulerLike): OperatorFunction; export declare function expand(project: (value: T, index: number) => ObservableInput, concurrent: number | undefined, scheduler: SchedulerLike): OperatorFunction; -export declare function filter(predicate: (value: T, index: number) => false, thisArg?: any): OperatorFunction; export declare function filter(predicate: (value: T, index: number) => value is S, thisArg?: any): OperatorFunction; export declare function filter(predicate: BooleanConstructor): OperatorFunction>; export declare function filter(predicate: (value: T, index: number) => boolean, thisArg?: any): MonoTypeOperatorFunction; diff --git a/spec-dtslint/operators/filter-spec.ts b/spec-dtslint/operators/filter-spec.ts index b453f794b2..fe8c74e498 100644 --- a/spec-dtslint/operators/filter-spec.ts +++ b/spec-dtslint/operators/filter-spec.ts @@ -53,10 +53,6 @@ it('should support Boolean as a predicate', () => { const x = of(false, false, false, false).pipe(filter(Boolean)); // $ExpectType Observable }); -it('should narrow on always-false predicates', () => { - const o = of(1, 2, 3).pipe(filter(() => false)); // $ExpectType Observable -}); - // I've not been able to effect a failing dtslint test for this situation and a // conventional test won't fail because the TypeScript configuration isn't // sufficiently strict: @@ -79,3 +75,11 @@ it('should support inference from a generic return type of the predicate', () => const o$ = of(1, null, {foo: 'bar'}, true, undefined, 'Nick Cage').pipe(filter(isDefined())); // $ExpectType Observable }); + +it('should support inference from a predicate that returns any', () => { + function isTruthy(value: number): any { + return !!value; + } + + const o$ = of(1).pipe(filter(isTruthy)); // $ExpectType Observable +}); diff --git a/src/internal/operators/filter.ts b/src/internal/operators/filter.ts index 3e7aaa3c9e..9cc609262a 100644 --- a/src/internal/operators/filter.ts +++ b/src/internal/operators/filter.ts @@ -3,7 +3,6 @@ import { OperatorFunction, MonoTypeOperatorFunction, TruthyTypesOf } from '../ty import { operate } from '../util/lift'; import { OperatorSubscriber } from './OperatorSubscriber'; -export function filter(predicate: (value: T, index: number) => false, thisArg?: any): OperatorFunction; export function filter(predicate: (value: T, index: number) => value is S, thisArg?: any): OperatorFunction; export function filter(predicate: BooleanConstructor): OperatorFunction>; export function filter(predicate: (value: T, index: number) => boolean, thisArg?: any): MonoTypeOperatorFunction;