Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

no-unnecessary-generics rule within callbacks #273

Open

Description

The unnecessary-generics rule seems to not consider callbacks, this code is flagged by the rule:

export function get<T>(key: string, callback: (data: T | {}) => void): void;

However, in this case the type parameter T might have been used only once, but it has the effect that typing is enforced when using the callback and therefore the generics isn't unnecessary and cannot be replaced by anything else with the same typing effect. E.g the above function can now be called with

get<{something: string}>("bla", (data) => /* data has the corecct type here */);

Am I missing something?

Activity

  1. changed the title [-]no-unnecessary-generics rule[/-] [+]no-unnecessary-generics rule within callbacks[/+] on Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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