From 6c16ea3adc2a38f50ab792f7813ed5cd1f1a6484 Mon Sep 17 00:00:00 2001 From: Nicholas Jamieson Date: Wed, 5 May 2021 19:00:18 +1000 Subject: [PATCH 1/4] chore: deprecate thisArg --- src/internal/observable/partition.ts | 2 ++ src/internal/operators/every.ts | 5 ++++- src/internal/operators/filter.ts | 2 ++ src/internal/operators/find.ts | 2 ++ src/internal/operators/findIndex.ts | 5 ++++- src/internal/operators/map.ts | 1 + 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/internal/observable/partition.ts b/src/internal/observable/partition.ts index d617a43803..6e9fee2866 100644 --- a/src/internal/observable/partition.ts +++ b/src/internal/observable/partition.ts @@ -4,6 +4,7 @@ import { ObservableInput } from '../types'; import { Observable } from '../Observable'; import { innerFrom } from './from'; +/** @deprecated Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8. */ export function partition( source: ObservableInput, predicate: (this: A, value: T, index: number) => value is U, @@ -14,6 +15,7 @@ export function partition( predicate: (value: T, index: number) => value is U ): [Observable, Observable>]; +/** @deprecated Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8. */ export function partition( source: ObservableInput, predicate: (this: A, value: T, index: number) => boolean, diff --git a/src/internal/operators/every.ts b/src/internal/operators/every.ts index 0d91df0e9a..c7c52d4bcb 100644 --- a/src/internal/operators/every.ts +++ b/src/internal/operators/every.ts @@ -3,10 +3,13 @@ import { Falsy, OperatorFunction } from '../types'; import { operate } from '../util/lift'; import { OperatorSubscriber } from './OperatorSubscriber'; +export function every(predicate: BooleanConstructor): OperatorFunction extends never ? false : boolean>; +/** @deprecated Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8. */ export function every( predicate: BooleanConstructor, - thisArg?: any + thisArg: any ): OperatorFunction extends never ? false : boolean>; +/** @deprecated Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8. */ export function every( predicate: (this: A, value: T, index: number, source: Observable) => boolean, thisArg: A diff --git a/src/internal/operators/filter.ts b/src/internal/operators/filter.ts index 16bdcde5c6..420e98f8e1 100644 --- a/src/internal/operators/filter.ts +++ b/src/internal/operators/filter.ts @@ -2,9 +2,11 @@ import { OperatorFunction, MonoTypeOperatorFunction, TruthyTypesOf } from '../ty import { operate } from '../util/lift'; import { OperatorSubscriber } from './OperatorSubscriber'; +/** @deprecated Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8. */ export function filter(predicate: (this: A, value: T, index: number) => value is S, thisArg: A): OperatorFunction; export function filter(predicate: (value: T, index: number) => value is S): OperatorFunction; export function filter(predicate: BooleanConstructor): OperatorFunction>; +/** @deprecated Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8. */ export function filter(predicate: (this: A, value: T, index: number) => boolean, thisArg: A): MonoTypeOperatorFunction; export function filter(predicate: (value: T, index: number) => boolean): MonoTypeOperatorFunction; diff --git a/src/internal/operators/find.ts b/src/internal/operators/find.ts index c09494574a..2b51163a1f 100644 --- a/src/internal/operators/find.ts +++ b/src/internal/operators/find.ts @@ -5,6 +5,7 @@ import { operate } from '../util/lift'; import { OperatorSubscriber } from './OperatorSubscriber'; export function find(predicate: BooleanConstructor): OperatorFunction>; +/** @deprecated Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8. */ export function find( predicate: (this: A, value: T, index: number, source: Observable) => value is S, thisArg: A @@ -12,6 +13,7 @@ export function find( export function find( predicate: (value: T, index: number, source: Observable) => value is S ): OperatorFunction; +/** @deprecated Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8. */ export function find( predicate: (this: A, value: T, index: number, source: Observable) => boolean, thisArg: A diff --git a/src/internal/operators/findIndex.ts b/src/internal/operators/findIndex.ts index 7c476c5b0f..52a0f23893 100644 --- a/src/internal/operators/findIndex.ts +++ b/src/internal/operators/findIndex.ts @@ -3,7 +3,10 @@ import { Falsy, OperatorFunction } from '../types'; import { operate } from '../util/lift'; import { createFind } from './find'; -export function findIndex(predicate: BooleanConstructor, thisArg?: any): OperatorFunction; +export function findIndex(predicate: BooleanConstructor): OperatorFunction; +/** @deprecated Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8. */ +export function findIndex(predicate: BooleanConstructor, thisArg: any): OperatorFunction; +/** @deprecated Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8. */ export function findIndex( predicate: (this: A, value: T, index: number, source: Observable) => boolean, thisArg: A diff --git a/src/internal/operators/map.ts b/src/internal/operators/map.ts index 6261392007..3e4e513558 100644 --- a/src/internal/operators/map.ts +++ b/src/internal/operators/map.ts @@ -3,6 +3,7 @@ import { operate } from '../util/lift'; import { OperatorSubscriber } from './OperatorSubscriber'; export function map(project: (value: T, index: number) => R): OperatorFunction; +/** @deprecated Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8. */ export function map(project: (this: A, value: T, index: number) => R, thisArg: A): OperatorFunction; /** From 8bb2f84d99bd71847dcc4c415271b30095c14ef1 Mon Sep 17 00:00:00 2001 From: Nicholas Jamieson Date: Wed, 5 May 2021 19:34:33 +1000 Subject: [PATCH 2/4] chore: deprecate source parameters Closes #6143 --- src/internal/operators/every.ts | 2 ++ src/internal/operators/find.ts | 5 +++++ src/internal/operators/findIndex.ts | 2 ++ src/internal/operators/first.ts | 6 ++++++ src/internal/operators/last.ts | 4 ++++ src/internal/operators/single.ts | 2 ++ 6 files changed, 21 insertions(+) diff --git a/src/internal/operators/every.ts b/src/internal/operators/every.ts index c7c52d4bcb..5d3d9f4934 100644 --- a/src/internal/operators/every.ts +++ b/src/internal/operators/every.ts @@ -14,6 +14,8 @@ export function every( predicate: (this: A, value: T, index: number, source: Observable) => boolean, thisArg: A ): OperatorFunction; +export function every(predicate: (value: T, index: number) => boolean): OperatorFunction; +/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function every(predicate: (value: T, index: number, source: Observable) => boolean): OperatorFunction; /** diff --git a/src/internal/operators/find.ts b/src/internal/operators/find.ts index 2b51163a1f..fd8fbd7aad 100644 --- a/src/internal/operators/find.ts +++ b/src/internal/operators/find.ts @@ -10,6 +10,8 @@ export function find( predicate: (this: A, value: T, index: number, source: Observable) => value is S, thisArg: A ): OperatorFunction; +export function find(predicate: (value: T, index: number) => value is S): OperatorFunction; +/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function find( predicate: (value: T, index: number, source: Observable) => value is S ): OperatorFunction; @@ -18,7 +20,10 @@ export function find( predicate: (this: A, value: T, index: number, source: Observable) => boolean, thisArg: A ): OperatorFunction; +export function find(predicate: (value: T, index: number) => boolean): OperatorFunction; +/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function find(predicate: (value: T, index: number, source: Observable) => boolean): OperatorFunction; + /** * Emits only the first value emitted by the source Observable that meets some * condition. diff --git a/src/internal/operators/findIndex.ts b/src/internal/operators/findIndex.ts index 52a0f23893..f05cd3b0a2 100644 --- a/src/internal/operators/findIndex.ts +++ b/src/internal/operators/findIndex.ts @@ -11,6 +11,8 @@ export function findIndex( predicate: (this: A, value: T, index: number, source: Observable) => boolean, thisArg: A ): OperatorFunction; +export function findIndex(predicate: (value: T, index: number) => boolean): OperatorFunction; +/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function findIndex(predicate: (value: T, index: number, source: Observable) => boolean): OperatorFunction; /** diff --git a/src/internal/operators/first.ts b/src/internal/operators/first.ts index e96bd7337a..4df8ba81cd 100644 --- a/src/internal/operators/first.ts +++ b/src/internal/operators/first.ts @@ -10,14 +10,20 @@ import { identity } from '../util/identity'; export function first(predicate?: null, defaultValue?: D): OperatorFunction; export function first(predicate: BooleanConstructor): OperatorFunction>; export function first(predicate: BooleanConstructor, defaultValue: D): OperatorFunction | D>; +export function first(predicate: (value: T, index: number) => value is S, defaultValue?: S): OperatorFunction; +/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function first( predicate: (value: T, index: number, source: Observable) => value is S, defaultValue?: S ): OperatorFunction; +export function first(predicate: (value: T, index: number) => value is S, defaultValue: D): OperatorFunction; +/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function first( predicate: (value: T, index: number, source: Observable) => value is S, defaultValue: D ): OperatorFunction; +export function first(predicate: (value: T, index: number) => boolean, defaultValue?: D): OperatorFunction; +/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function first( predicate: (value: T, index: number, source: Observable) => boolean, defaultValue?: D diff --git a/src/internal/operators/last.ts b/src/internal/operators/last.ts index 5117db061a..40798e47dc 100644 --- a/src/internal/operators/last.ts +++ b/src/internal/operators/last.ts @@ -10,10 +10,14 @@ import { identity } from '../util/identity'; export function last(predicate: BooleanConstructor): OperatorFunction>; export function last(predicate: BooleanConstructor, defaultValue: D): OperatorFunction | D>; export function last(predicate?: null, defaultValue?: D): OperatorFunction; +export function last(predicate: (value: T, index: number) => value is S, defaultValue?: S): OperatorFunction; +export function last(predicate: (value: T, index: number) => boolean, defaultValue?: D): OperatorFunction; +/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function last( predicate: (value: T, index: number, source: Observable) => value is S, defaultValue?: S ): OperatorFunction; +/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function last( predicate: (value: T, index: number, source: Observable) => boolean, defaultValue?: D diff --git a/src/internal/operators/single.ts b/src/internal/operators/single.ts index e4151a6aa1..3cf0685878 100644 --- a/src/internal/operators/single.ts +++ b/src/internal/operators/single.ts @@ -8,6 +8,8 @@ import { operate } from '../util/lift'; import { OperatorSubscriber } from './OperatorSubscriber'; export function single(predicate: BooleanConstructor): OperatorFunction>; +export function single(predicate?: (value: T, index: number) => boolean): MonoTypeOperatorFunction; +/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function single(predicate?: (value: T, index: number, source: Observable) => boolean): MonoTypeOperatorFunction; /** From aec4c88aa0380b40a036506726f34258886ca3ae Mon Sep 17 00:00:00 2001 From: Nicholas Jamieson Date: Thu, 6 May 2021 16:58:31 +1000 Subject: [PATCH 3/4] Revert "chore: deprecate source parameters" This reverts commit 8bb2f84d99bd71847dcc4c415271b30095c14ef1. Closes #6143. --- src/internal/operators/every.ts | 2 -- src/internal/operators/find.ts | 5 ----- src/internal/operators/findIndex.ts | 2 -- src/internal/operators/first.ts | 6 ------ src/internal/operators/last.ts | 4 ---- src/internal/operators/single.ts | 2 -- 6 files changed, 21 deletions(-) diff --git a/src/internal/operators/every.ts b/src/internal/operators/every.ts index 5d3d9f4934..c7c52d4bcb 100644 --- a/src/internal/operators/every.ts +++ b/src/internal/operators/every.ts @@ -14,8 +14,6 @@ export function every( predicate: (this: A, value: T, index: number, source: Observable) => boolean, thisArg: A ): OperatorFunction; -export function every(predicate: (value: T, index: number) => boolean): OperatorFunction; -/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function every(predicate: (value: T, index: number, source: Observable) => boolean): OperatorFunction; /** diff --git a/src/internal/operators/find.ts b/src/internal/operators/find.ts index fd8fbd7aad..2b51163a1f 100644 --- a/src/internal/operators/find.ts +++ b/src/internal/operators/find.ts @@ -10,8 +10,6 @@ export function find( predicate: (this: A, value: T, index: number, source: Observable) => value is S, thisArg: A ): OperatorFunction; -export function find(predicate: (value: T, index: number) => value is S): OperatorFunction; -/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function find( predicate: (value: T, index: number, source: Observable) => value is S ): OperatorFunction; @@ -20,10 +18,7 @@ export function find( predicate: (this: A, value: T, index: number, source: Observable) => boolean, thisArg: A ): OperatorFunction; -export function find(predicate: (value: T, index: number) => boolean): OperatorFunction; -/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function find(predicate: (value: T, index: number, source: Observable) => boolean): OperatorFunction; - /** * Emits only the first value emitted by the source Observable that meets some * condition. diff --git a/src/internal/operators/findIndex.ts b/src/internal/operators/findIndex.ts index f05cd3b0a2..52a0f23893 100644 --- a/src/internal/operators/findIndex.ts +++ b/src/internal/operators/findIndex.ts @@ -11,8 +11,6 @@ export function findIndex( predicate: (this: A, value: T, index: number, source: Observable) => boolean, thisArg: A ): OperatorFunction; -export function findIndex(predicate: (value: T, index: number) => boolean): OperatorFunction; -/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function findIndex(predicate: (value: T, index: number, source: Observable) => boolean): OperatorFunction; /** diff --git a/src/internal/operators/first.ts b/src/internal/operators/first.ts index 4df8ba81cd..e96bd7337a 100644 --- a/src/internal/operators/first.ts +++ b/src/internal/operators/first.ts @@ -10,20 +10,14 @@ import { identity } from '../util/identity'; export function first(predicate?: null, defaultValue?: D): OperatorFunction; export function first(predicate: BooleanConstructor): OperatorFunction>; export function first(predicate: BooleanConstructor, defaultValue: D): OperatorFunction | D>; -export function first(predicate: (value: T, index: number) => value is S, defaultValue?: S): OperatorFunction; -/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function first( predicate: (value: T, index: number, source: Observable) => value is S, defaultValue?: S ): OperatorFunction; -export function first(predicate: (value: T, index: number) => value is S, defaultValue: D): OperatorFunction; -/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function first( predicate: (value: T, index: number, source: Observable) => value is S, defaultValue: D ): OperatorFunction; -export function first(predicate: (value: T, index: number) => boolean, defaultValue?: D): OperatorFunction; -/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function first( predicate: (value: T, index: number, source: Observable) => boolean, defaultValue?: D diff --git a/src/internal/operators/last.ts b/src/internal/operators/last.ts index 40798e47dc..5117db061a 100644 --- a/src/internal/operators/last.ts +++ b/src/internal/operators/last.ts @@ -10,14 +10,10 @@ import { identity } from '../util/identity'; export function last(predicate: BooleanConstructor): OperatorFunction>; export function last(predicate: BooleanConstructor, defaultValue: D): OperatorFunction | D>; export function last(predicate?: null, defaultValue?: D): OperatorFunction; -export function last(predicate: (value: T, index: number) => value is S, defaultValue?: S): OperatorFunction; -export function last(predicate: (value: T, index: number) => boolean, defaultValue?: D): OperatorFunction; -/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function last( predicate: (value: T, index: number, source: Observable) => value is S, defaultValue?: S ): OperatorFunction; -/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function last( predicate: (value: T, index: number, source: Observable) => boolean, defaultValue?: D diff --git a/src/internal/operators/single.ts b/src/internal/operators/single.ts index 3cf0685878..e4151a6aa1 100644 --- a/src/internal/operators/single.ts +++ b/src/internal/operators/single.ts @@ -8,8 +8,6 @@ import { operate } from '../util/lift'; import { OperatorSubscriber } from './OperatorSubscriber'; export function single(predicate: BooleanConstructor): OperatorFunction>; -export function single(predicate?: (value: T, index: number) => boolean): MonoTypeOperatorFunction; -/** @deprecated Use a closure instead of a `source` parameter. Support for predicates taking a `source` parameter will be removed in v8. */ export function single(predicate?: (value: T, index: number, source: Observable) => boolean): MonoTypeOperatorFunction; /** From 891c9b798aadec052317c0ddac5283564de7ac0f Mon Sep 17 00:00:00 2001 From: Nicholas Jamieson Date: Thu, 6 May 2021 17:03:36 +1000 Subject: [PATCH 4/4] chore: update api_guardian --- api_guard/dist/types/operators/index.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api_guard/dist/types/operators/index.d.ts b/api_guard/dist/types/operators/index.d.ts index cfff96d807..c11c8e38d9 100644 --- a/api_guard/dist/types/operators/index.d.ts +++ b/api_guard/dist/types/operators/index.d.ts @@ -76,7 +76,8 @@ export declare function endWith(scheduler: SchedulerLike): MonoTypeOperatorFu export declare function endWith(...valuesAndScheduler: [...A, SchedulerLike]): OperatorFunction>; export declare function endWith(...values: A): OperatorFunction>; -export declare function every(predicate: BooleanConstructor, thisArg?: any): OperatorFunction extends never ? false : boolean>; +export declare function every(predicate: BooleanConstructor): OperatorFunction extends never ? false : boolean>; +export declare function every(predicate: BooleanConstructor, thisArg: any): OperatorFunction extends never ? false : boolean>; export declare function every(predicate: (this: A, value: T, index: number, source: Observable) => boolean, thisArg: A): OperatorFunction; export declare function every(predicate: (value: T, index: number, source: Observable) => boolean): OperatorFunction; @@ -105,7 +106,8 @@ export declare function find(predicate: (value: T, index: number export declare function find(predicate: (this: A, value: T, index: number, source: Observable) => boolean, thisArg: A): OperatorFunction; export declare function find(predicate: (value: T, index: number, source: Observable) => boolean): OperatorFunction; -export declare function findIndex(predicate: BooleanConstructor, thisArg?: any): OperatorFunction; +export declare function findIndex(predicate: BooleanConstructor): OperatorFunction; +export declare function findIndex(predicate: BooleanConstructor, thisArg: any): OperatorFunction; export declare function findIndex(predicate: (this: A, value: T, index: number, source: Observable) => boolean, thisArg: A): OperatorFunction; export declare function findIndex(predicate: (value: T, index: number, source: Observable) => boolean): OperatorFunction;