From af1a9f446a860883abaa36ace21345dc923e7e53 Mon Sep 17 00:00:00 2001 From: Yadong Xie Date: Sun, 4 Dec 2022 03:00:45 +0800 Subject: [PATCH] fix: subscribe and tap type overloads (#6718) * fix: observable subscribe overloads close #6717 * fix: tap operator overloads --- api_guard/dist/types/index.d.ts | 6 ++---- api_guard/dist/types/operators/index.d.ts | 3 +-- src/internal/Observable.ts | 3 +-- src/internal/operators/tap.ts | 4 +--- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/api_guard/dist/types/index.d.ts b/api_guard/dist/types/index.d.ts index 387e385a6b..471963336c 100644 --- a/api_guard/dist/types/index.d.ts +++ b/api_guard/dist/types/index.d.ts @@ -451,8 +451,7 @@ export declare class Observable implements Subscribable { pipe(op1: OperatorFunction, op2: OperatorFunction, op3: OperatorFunction, op4: OperatorFunction, op5: OperatorFunction, op6: OperatorFunction, op7: OperatorFunction, op8: OperatorFunction): Observable; pipe(op1: OperatorFunction, op2: OperatorFunction, op3: OperatorFunction, op4: OperatorFunction, op5: OperatorFunction, op6: OperatorFunction, op7: OperatorFunction, op8: OperatorFunction, op9: OperatorFunction): Observable; pipe(op1: OperatorFunction, op2: OperatorFunction, op3: OperatorFunction, op4: OperatorFunction, op5: OperatorFunction, op6: OperatorFunction, op7: OperatorFunction, op8: OperatorFunction, op9: OperatorFunction, ...operations: OperatorFunction[]): Observable; - subscribe(observer?: Partial>): Subscription; - subscribe(next: (value: T) => void): Subscription; + subscribe(observerOrNext?: Partial> | ((value: T) => void)): Subscription; subscribe(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): Subscription; toPromise(): Promise; toPromise(PromiseCtor: typeof Promise): Promise; @@ -750,8 +749,7 @@ export declare function takeWhile(predicate: (value: T, index: n export declare function takeWhile(predicate: (value: T, index: number) => value is S, inclusive: false): OperatorFunction; export declare function takeWhile(predicate: (value: T, index: number) => boolean, inclusive?: boolean): MonoTypeOperatorFunction; -export declare function tap(observer?: Partial>): MonoTypeOperatorFunction; -export declare function tap(next: (value: T) => void): MonoTypeOperatorFunction; +export declare function tap(observerOrNext?: Partial> | ((value: T) => void)): MonoTypeOperatorFunction; export declare function tap(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): MonoTypeOperatorFunction; export declare type TeardownLogic = Subscription | Unsubscribable | (() => void) | void; diff --git a/api_guard/dist/types/operators/index.d.ts b/api_guard/dist/types/operators/index.d.ts index 4d673c5b08..4f0b8b61ca 100644 --- a/api_guard/dist/types/operators/index.d.ts +++ b/api_guard/dist/types/operators/index.d.ts @@ -319,8 +319,7 @@ export declare function takeWhile(predicate: (value: T, index: n export declare function takeWhile(predicate: (value: T, index: number) => value is S, inclusive: false): OperatorFunction; export declare function takeWhile(predicate: (value: T, index: number) => boolean, inclusive?: boolean): MonoTypeOperatorFunction; -export declare function tap(observer?: Partial>): MonoTypeOperatorFunction; -export declare function tap(next: (value: T) => void): MonoTypeOperatorFunction; +export declare function tap(observerOrNext?: Partial> | ((value: T) => void)): MonoTypeOperatorFunction; export declare function tap(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): MonoTypeOperatorFunction; export declare function throttle(durationSelector: (value: T) => ObservableInput, config?: ThrottleConfig): MonoTypeOperatorFunction; diff --git a/src/internal/Observable.ts b/src/internal/Observable.ts index c74509d30f..c40a6ded4d 100644 --- a/src/internal/Observable.ts +++ b/src/internal/Observable.ts @@ -71,8 +71,7 @@ export class Observable implements Subscribable { return observable; } - subscribe(observer?: Partial>): Subscription; - subscribe(next: (value: T) => void): Subscription; + subscribe(observerOrNext?: Partial> | ((value: T) => void)): Subscription; /** @deprecated Instead of passing separate callback arguments, use an observer argument. Signatures taking separate callback arguments will be removed in v8. Details: https://rxjs.dev/deprecations/subscribe-arguments */ subscribe(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): Subscription; /** diff --git a/src/internal/operators/tap.ts b/src/internal/operators/tap.ts index cc0063d0ad..1ee94e36db 100644 --- a/src/internal/operators/tap.ts +++ b/src/internal/operators/tap.ts @@ -9,9 +9,7 @@ export interface TapObserver extends Observer { unsubscribe: () => void; finalize: () => void; } - -export function tap(observer?: Partial>): MonoTypeOperatorFunction; -export function tap(next: (value: T) => void): MonoTypeOperatorFunction; +export function tap(observerOrNext?: Partial> | ((value: T) => void)): MonoTypeOperatorFunction; /** @deprecated Instead of passing separate callback arguments, use an observer argument. Signatures taking separate callback arguments will be removed in v8. Details: https://rxjs.dev/deprecations/subscribe-arguments */ export function tap( next?: ((value: T) => void) | null,