diff --git a/spec-dtslint/operators/repeatWhen-spec.ts b/spec-dtslint/operators/repeatWhen-spec.ts new file mode 100644 index 0000000000..0290394ff7 --- /dev/null +++ b/spec-dtslint/operators/repeatWhen-spec.ts @@ -0,0 +1,22 @@ +import { of } from 'rxjs'; +import { repeatWhen } from 'rxjs/operators'; + +it('should infer correctly', () => { + const o = of(1, 2, 3).pipe(repeatWhen(errors => errors)); // $ExpectType Observable +}); + +it('should infer correctly when the error observable has a different type', () => { + const o = of(1, 2, 3).pipe(repeatWhen(repeatWhen(errors => of('a', 'b', 'c')))); // $ExpectType Observable +}); + +it('should enforce types', () => { + const o = of(1, 2, 3).pipe(repeatWhen()); // $ExpectError +}); + +it('should enforce types of the notifier', () => { + const o = of(1, 2, 3).pipe(repeatWhen(() => 8)); // $ExpectError +}); + +it('should be deprecated', () => { + const o = of(1, 2, 3).pipe(repeatWhen(() => of(true))); // $ExpectDeprecation +}); \ No newline at end of file diff --git a/spec-dtslint/operators/retryWhen-spec.ts b/spec-dtslint/operators/retryWhen-spec.ts index 3e02efb309..14cef47877 100644 --- a/spec-dtslint/operators/retryWhen-spec.ts +++ b/spec-dtslint/operators/retryWhen-spec.ts @@ -16,3 +16,7 @@ it('should enforce types', () => { it('should enforce types of the notifier', () => { const o = of(1, 2, 3).pipe(retryWhen(() => 8)); // $ExpectError }); + +it('should be deprecated', () => { + const o = of(1, 2, 3).pipe(retryWhen(() => of(true))); // $ExpectDeprecation +}); \ No newline at end of file diff --git a/src/internal/operators/repeatWhen.ts b/src/internal/operators/repeatWhen.ts index 1f944c7428..8d3e0ded52 100644 --- a/src/internal/operators/repeatWhen.ts +++ b/src/internal/operators/repeatWhen.ts @@ -37,6 +37,7 @@ import { createOperatorSubscriber } from './OperatorSubscriber'; * which a user can `complete` or `error`, aborting the repetition. * @return A function that returns an Observable that that mirrors the source * Observable with the exception of a `complete`. + * @deprecated Will be removed in v9 or v10. Use {@link repeat}'s `delay` option instead. */ export function repeatWhen(notifier: (notifications: Observable) => Observable): MonoTypeOperatorFunction { return operate((source, subscriber) => { diff --git a/src/internal/operators/retryWhen.ts b/src/internal/operators/retryWhen.ts index 4c45e46477..66de2d577e 100644 --- a/src/internal/operators/retryWhen.ts +++ b/src/internal/operators/retryWhen.ts @@ -59,6 +59,7 @@ import { createOperatorSubscriber } from './OperatorSubscriber'; * user can `complete` or `error`, aborting the retry. * @return A function that returns an Observable that mirrors the source * Observable with the exception of an `error`. + * @deprecated: Will be removed in v9 or v10, use {@link retry}'s `delay` option instead. */ export function retryWhen(notifier: (errors: Observable) => Observable): MonoTypeOperatorFunction { return operate((source, subscriber) => {