From 0ec065dd3a6f3bfb56fcb6533b4b3ada4ab42a8b Mon Sep 17 00:00:00 2001 From: Michael Paul Date: Wed, 5 Jan 2022 09:51:24 -0500 Subject: [PATCH 1/2] fix: use "unknown" type for operators that ignore input values These operators ignore the values produced by the source Observable, so they don't need the dynamic typing that "any" would provide for accessing the values. Using "unknown" instead of "any" avoids warnings from eslint rules like @typescript-eslint/no-unsafe-argument in application code that uses the operators, and it's also a clearer way to express that the operators don't know or care what the source type is. --- src/internal/operators/concatMapTo.ts | 4 ++-- src/internal/operators/ignoreElements.ts | 2 +- src/internal/operators/mapTo.ts | 4 ++-- src/internal/operators/mergeMapTo.ts | 2 +- src/internal/operators/switchMapTo.ts | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/internal/operators/concatMapTo.ts b/src/internal/operators/concatMapTo.ts index 0fd8b253a9..b7503c3b9f 100644 --- a/src/internal/operators/concatMapTo.ts +++ b/src/internal/operators/concatMapTo.ts @@ -3,12 +3,12 @@ import { ObservableInput, OperatorFunction, ObservedValueOf } from '../types'; import { isFunction } from '../util/isFunction'; /* tslint:disable:max-line-length */ -export function concatMapTo>(observable: O): OperatorFunction>; +export function concatMapTo>(observable: O): OperatorFunction>; /** @deprecated The `resultSelector` parameter will be removed in v8. Use an inner `map` instead. Details: https://rxjs.dev/deprecations/resultSelector */ export function concatMapTo>( observable: O, resultSelector: undefined -): OperatorFunction>; +): OperatorFunction>; /** @deprecated The `resultSelector` parameter will be removed in v8. Use an inner `map` instead. Details: https://rxjs.dev/deprecations/resultSelector */ export function concatMapTo>( observable: O, diff --git a/src/internal/operators/ignoreElements.ts b/src/internal/operators/ignoreElements.ts index 4b85c9c27d..2663f7ff18 100644 --- a/src/internal/operators/ignoreElements.ts +++ b/src/internal/operators/ignoreElements.ts @@ -38,7 +38,7 @@ import { noop } from '../util/noop'; * `complete` or `error`, based on which one is called by the source * Observable. */ -export function ignoreElements(): OperatorFunction { +export function ignoreElements(): OperatorFunction { return operate((source, subscriber) => { source.subscribe(new OperatorSubscriber(subscriber, noop)); }); diff --git a/src/internal/operators/mapTo.ts b/src/internal/operators/mapTo.ts index 0f8c72a1ec..1caab7eac3 100644 --- a/src/internal/operators/mapTo.ts +++ b/src/internal/operators/mapTo.ts @@ -1,7 +1,7 @@ import { OperatorFunction } from '../types'; import { map } from './map'; -export function mapTo(value: R): OperatorFunction; +export function mapTo(value: R): OperatorFunction; /** @deprecated Do not specify explicit type parameters. Signatures with type parameters that cannot be inferred will be removed in v8. */ export function mapTo(value: R): OperatorFunction; @@ -37,6 +37,6 @@ export function mapTo(value: R): OperatorFunction; * @return A function that returns an Observable that emits the given `value` * every time the source Observable emits. */ -export function mapTo(value: R): OperatorFunction { +export function mapTo(value: R): OperatorFunction { return map(() => value); } diff --git a/src/internal/operators/mergeMapTo.ts b/src/internal/operators/mergeMapTo.ts index 28849a2669..4a2eeeedbf 100644 --- a/src/internal/operators/mergeMapTo.ts +++ b/src/internal/operators/mergeMapTo.ts @@ -6,7 +6,7 @@ import { isFunction } from '../util/isFunction'; export function mergeMapTo>( innerObservable: O, concurrent?: number -): OperatorFunction>; +): OperatorFunction>; /** @deprecated The `resultSelector` parameter will be removed in v8. Use an inner `map` instead. Details: https://rxjs.dev/deprecations/resultSelector */ export function mergeMapTo>( innerObservable: O, diff --git a/src/internal/operators/switchMapTo.ts b/src/internal/operators/switchMapTo.ts index a3ff875fe9..1436204f70 100644 --- a/src/internal/operators/switchMapTo.ts +++ b/src/internal/operators/switchMapTo.ts @@ -3,12 +3,12 @@ import { ObservableInput, OperatorFunction, ObservedValueOf } from '../types'; import { isFunction } from '../util/isFunction'; /* tslint:disable:max-line-length */ -export function switchMapTo>(observable: O): OperatorFunction>; +export function switchMapTo>(observable: O): OperatorFunction>; /** @deprecated The `resultSelector` parameter will be removed in v8. Use an inner `map` instead. Details: https://rxjs.dev/deprecations/resultSelector */ export function switchMapTo>( observable: O, resultSelector: undefined -): OperatorFunction>; +): OperatorFunction>; /** @deprecated The `resultSelector` parameter will be removed in v8. Use an inner `map` instead. Details: https://rxjs.dev/deprecations/resultSelector */ export function switchMapTo>( observable: O, From 044420b8167528f9090dcc36f02a64773e8cf963 Mon Sep 17 00:00:00 2001 From: Michael Paul Date: Sat, 8 Jan 2022 14:39:12 -0500 Subject: [PATCH 2/2] fix: update api_guard files to reflect intentional API change --- api_guard/dist/types/index.d.ts | 14 +++++++------- api_guard/dist/types/operators/index.d.ts | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/api_guard/dist/types/index.d.ts b/api_guard/dist/types/index.d.ts index 7cfc595493..1a14efdf38 100644 --- a/api_guard/dist/types/index.d.ts +++ b/api_guard/dist/types/index.d.ts @@ -108,8 +108,8 @@ export declare function concatMap>(project: (v export declare function concatMap>(project: (value: T, index: number) => O, resultSelector: undefined): OperatorFunction>; export declare function concatMap>(project: (value: T, index: number) => O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R): OperatorFunction; -export declare function concatMapTo>(observable: O): OperatorFunction>; -export declare function concatMapTo>(observable: O, resultSelector: undefined): OperatorFunction>; +export declare function concatMapTo>(observable: O): OperatorFunction>; +export declare function concatMapTo>(observable: O, resultSelector: undefined): OperatorFunction>; export declare function concatMapTo>(observable: O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R): OperatorFunction; export declare function concatWith(...otherSources: [...ObservableInputTuple]): OperatorFunction; @@ -314,7 +314,7 @@ export declare type Head = ((...args: X) => any) exten export declare function identity(x: T): T; -export declare function ignoreElements(): OperatorFunction; +export declare function ignoreElements(): OperatorFunction; export declare function iif(condition: () => boolean, trueResult: ObservableInput, falseResult: ObservableInput): Observable; @@ -340,7 +340,7 @@ export declare function lastValueFrom(source: Observable): Promise; export declare function map(project: (value: T, index: number) => R): OperatorFunction; export declare function map(project: (this: A, value: T, index: number) => R, thisArg: A): OperatorFunction; -export declare function mapTo(value: R): OperatorFunction; +export declare function mapTo(value: R): OperatorFunction; export declare function mapTo(value: R): OperatorFunction; export declare function materialize(): OperatorFunction & ObservableNotification>; @@ -358,7 +358,7 @@ export declare function mergeMap>(project: (va export declare function mergeMap>(project: (value: T, index: number) => O, resultSelector: undefined, concurrent?: number): OperatorFunction>; export declare function mergeMap>(project: (value: T, index: number) => O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R, concurrent?: number): OperatorFunction; -export declare function mergeMapTo>(innerObservable: O, concurrent?: number): OperatorFunction>; +export declare function mergeMapTo>(innerObservable: O, concurrent?: number): OperatorFunction>; export declare function mergeMapTo>(innerObservable: O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R, concurrent?: number): OperatorFunction; export declare function mergeScan(accumulator: (acc: R, value: T, index: number) => ObservableInput, seed: R, concurrent?: number): OperatorFunction; @@ -729,8 +729,8 @@ export declare function switchMap>(project: (v export declare function switchMap>(project: (value: T, index: number) => O, resultSelector: undefined): OperatorFunction>; export declare function switchMap>(project: (value: T, index: number) => O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R): OperatorFunction; -export declare function switchMapTo>(observable: O): OperatorFunction>; -export declare function switchMapTo>(observable: O, resultSelector: undefined): OperatorFunction>; +export declare function switchMapTo>(observable: O): OperatorFunction>; +export declare function switchMapTo>(observable: O, resultSelector: undefined): OperatorFunction>; export declare function switchMapTo>(observable: O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R): OperatorFunction; export declare function switchScan>(accumulator: (acc: R, value: T, index: number) => O, seed: R): OperatorFunction>; diff --git a/api_guard/dist/types/operators/index.d.ts b/api_guard/dist/types/operators/index.d.ts index 034286c140..4d673c5b08 100644 --- a/api_guard/dist/types/operators/index.d.ts +++ b/api_guard/dist/types/operators/index.d.ts @@ -45,8 +45,8 @@ export declare function concatMap>(project: (v export declare function concatMap>(project: (value: T, index: number) => O, resultSelector: undefined): OperatorFunction>; export declare function concatMap>(project: (value: T, index: number) => O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R): OperatorFunction; -export declare function concatMapTo>(observable: O): OperatorFunction>; -export declare function concatMapTo>(observable: O, resultSelector: undefined): OperatorFunction>; +export declare function concatMapTo>(observable: O): OperatorFunction>; +export declare function concatMapTo>(observable: O, resultSelector: undefined): OperatorFunction>; export declare function concatMapTo>(observable: O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R): OperatorFunction; export declare function concatWith(...otherSources: [...ObservableInputTuple]): OperatorFunction; @@ -144,7 +144,7 @@ export interface GroupByOptionsWithElement { element: (value: T) => E; } -export declare function ignoreElements(): OperatorFunction; +export declare function ignoreElements(): OperatorFunction; export declare function isEmpty(): OperatorFunction; @@ -157,7 +157,7 @@ export declare function last(predicate: (value: T, index: number, sour export declare function map(project: (value: T, index: number) => R): OperatorFunction; export declare function map(project: (this: A, value: T, index: number) => R, thisArg: A): OperatorFunction; -export declare function mapTo(value: R): OperatorFunction; +export declare function mapTo(value: R): OperatorFunction; export declare function mapTo(value: R): OperatorFunction; export declare function materialize(): OperatorFunction & ObservableNotification>; @@ -175,7 +175,7 @@ export declare function mergeMap>(project: (va export declare function mergeMap>(project: (value: T, index: number) => O, resultSelector: undefined, concurrent?: number): OperatorFunction>; export declare function mergeMap>(project: (value: T, index: number) => O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R, concurrent?: number): OperatorFunction; -export declare function mergeMapTo>(innerObservable: O, concurrent?: number): OperatorFunction>; +export declare function mergeMapTo>(innerObservable: O, concurrent?: number): OperatorFunction>; export declare function mergeMapTo>(innerObservable: O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R, concurrent?: number): OperatorFunction; export declare function mergeScan(accumulator: (acc: R, value: T, index: number) => ObservableInput, seed: R, concurrent?: number): OperatorFunction; @@ -300,8 +300,8 @@ export declare function switchMap>(project: (v export declare function switchMap>(project: (value: T, index: number) => O, resultSelector: undefined): OperatorFunction>; export declare function switchMap>(project: (value: T, index: number) => O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R): OperatorFunction; -export declare function switchMapTo>(observable: O): OperatorFunction>; -export declare function switchMapTo>(observable: O, resultSelector: undefined): OperatorFunction>; +export declare function switchMapTo>(observable: O): OperatorFunction>; +export declare function switchMapTo>(observable: O, resultSelector: undefined): OperatorFunction>; export declare function switchMapTo>(observable: O, resultSelector: (outerValue: T, innerValue: ObservedValueOf, outerIndex: number, innerIndex: number) => R): OperatorFunction; export declare function switchScan>(accumulator: (acc: R, value: T, index: number) => O, seed: R): OperatorFunction>;