diff --git a/spec-dtslint/operators/takeWhile-spec.ts b/spec-dtslint/operators/takeWhile-spec.ts index 8534fe748e4..f683bd14635 100644 --- a/spec-dtslint/operators/takeWhile-spec.ts +++ b/spec-dtslint/operators/takeWhile-spec.ts @@ -20,9 +20,10 @@ it('should support a predicate with inclusive option', () => { it('should properly support Boolean constructor', () => { const a = of(false as const, 0 as const, -0 as const, 0n as const, '' as const, null, undefined).pipe(takeWhile(Boolean)); // $ExpectType Observable const b = of(false as const, 0 as const, -0 as const, 0n as const, '' as const, null, undefined).pipe(takeWhile(Boolean, true)); // $ExpectType Observable - const c = of(false as const, 0 as const, 'hi' as const, -0 as const, 0n as const, '' as const, null, undefined).pipe(takeWhile(Boolean)); // $ExpectType Observable - const d = of(false as const, 0 as const, 'hi' as const, -0 as const, 0n as const, '' as const, null, undefined).pipe(takeWhile(Boolean, true)); // $ExpectType Observable - const e = of(1, ['hi'], false as const, 0 as const, -0 as const, 0n as const, '' as const, null, undefined).pipe(takeWhile(Boolean, true)); // $ExpectType Observable + const c = of(false as const, 0 as const, 'hi' as const, -0 as const, 0n as const, '' as const, null, undefined).pipe(takeWhile(Boolean)); // $ExpectType Observable<"hi"> + const d = of(false as const, 0 as const, 'hi' as const, -0 as const, 0n as const, '' as const, null, undefined).pipe(takeWhile(Boolean, false)); // $ExpectType Observable<"hi"> + const e = of(false as const, 0 as const, 'hi' as const, -0 as const, 0n as const, '' as const, null, undefined).pipe(takeWhile(Boolean, true)); // $ExpectType Observable + const f = of(1, ['hi'], false as const, 0 as const, -0 as const, 0n as const, '' as const, null, undefined).pipe(takeWhile(Boolean, true)); // $ExpectType Observable }); it('should properly handle predicates that always return false', () => { @@ -36,4 +37,4 @@ it('should support inference from a predicate that returns any', () => { } const o$ = of(1).pipe(takeWhile(isTruthy)); // $ExpectType Observable -}); \ No newline at end of file +}); diff --git a/src/internal/operators/takeWhile.ts b/src/internal/operators/takeWhile.ts index 1ae3f0e8c0c..969256168ec 100644 --- a/src/internal/operators/takeWhile.ts +++ b/src/internal/operators/takeWhile.ts @@ -1,13 +1,10 @@ -import { OperatorFunction, MonoTypeOperatorFunction, Falsy } from '../types'; +import { OperatorFunction, MonoTypeOperatorFunction, TruthyTypesOf } from '../types'; import { operate } from '../util/lift'; import { OperatorSubscriber } from './OperatorSubscriber'; -export function takeWhile(predicate: BooleanConstructor): OperatorFunction extends never ? never : T>; -export function takeWhile( - predicate: BooleanConstructor, - inclusive: false -): OperatorFunction extends never ? never : T>; export function takeWhile(predicate: BooleanConstructor, inclusive: true): MonoTypeOperatorFunction; +export function takeWhile(predicate: BooleanConstructor, inclusive: false): OperatorFunction>; +export function takeWhile(predicate: BooleanConstructor): OperatorFunction>; export function takeWhile(predicate: (value: T, index: number) => value is S): OperatorFunction; export function takeWhile(predicate: (value: T, index: number) => value is S, inclusive: false): OperatorFunction; export function takeWhile(predicate: (value: T, index: number) => boolean, inclusive?: boolean): MonoTypeOperatorFunction;