Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/internal/operators/catchError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@ import { Observable } from '../Observable';

import { OuterSubscriber } from '../OuterSubscriber';
import { subscribeToResult } from '../util/subscribeToResult';
import { ObservableInput, OperatorFunction } from '../types';
import { ObservableInput, OperatorFunction, MonoTypeOperatorFunction } from '../types';

export function catchError<T>(
selector: (err: any, caught: Observable<T>) => never
): MonoTypeOperatorFunction<T>;

export function catchError<T>(
selector: (err: any, caught: Observable<T>) => ObservableInput<T>
): MonoTypeOperatorFunction<T>;

export function catchError<T, R>(
selector: (err: any, caught: Observable<T>) => ObservableInput<R>
): OperatorFunction<T, R>;

/**
* Catches errors on the observable to be handled by returning a new observable or throwing an error.
Expand Down Expand Up @@ -63,7 +75,7 @@ import { ObservableInput, OperatorFunction } from '../types';
* catch `selector` function.
* @name catchError
*/
export function catchError<T, R>(selector: (err: any, caught: Observable<T>) => ObservableInput<R>): OperatorFunction<T, T | R> {
export function catchError<T, R>(selector: (err: any, caught: Observable<T>) => ObservableInput<R>|never): OperatorFunction<T, T | R> {
return function catchErrorOperatorFunction(source: Observable<T>): Observable<T | R> {
const operator = new CatchOperator(selector);
const caught = source.lift(operator);
Expand Down