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

no-unnecessary-generics rule within callbacks #273

Open
Lagily opened this issue Feb 20, 2020 · 0 comments
Open

no-unnecessary-generics rule within callbacks #273

Lagily opened this issue Feb 20, 2020 · 0 comments

Comments

@Lagily
Copy link

Lagily commented Feb 20, 2020

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?

@Lagily Lagily changed the title no-unnecessary-generics rule no-unnecessary-generics rule within callbacks Feb 20, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant