Skip to content

After upgrade to 7.2.0 mapTo(true) violates and shows @typescript-eslint/no-unsafe-argument error #6536

@vitalyiegorov

Description

@vitalyiegorov

Bug Report

We have migrated our codebase from 6.6.6 to 7.2.0 and have a an issue for mapTo(true) operator from eslint:

ESLint: Unsafe argument of type `OperatorFunction<any, boolean>` assigned to a parameter of type `OperatorFunction<DeleteResult, boolean>`.(@typescript-eslint/no-unsafe-argument)

Investigating the sources:

export function mapTo<R>(value: R): OperatorFunction<any, R>;
/** @deprecated Do not specify explicit type parameters. Signatures with type parameters that cannot be inferred will be removed in v8. */
export function mapTo<T, R>(value: R): OperatorFunction<T, R>;

Current Behavior
ESLint error is shown, without providing generics for mapTo operator.

Expected behavior
No ESLint errors, without additional generics for mapTo operator.

Reproduction

mapTo(true)

Environment

  • Runtime: Node v16.1.0
  • RxJS version: 7.2.0

Possible Solution
Seems like the problem is with any, changing the type to use generics, fixes the issue, and you can use it in your code without specifying them:

export declare function mapTo<T, R>(value: R): OperatorFunction<T, R>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions