You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
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?
The text was updated successfully, but these errors were encountered:
Lagily
changed the title
no-unnecessary-generics rule
no-unnecessary-generics rule within callbacks
Feb 20, 2020
# for freeto subscribe to this conversation on GitHub.
Already have an account?
#.
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?
The text was updated successfully, but these errors were encountered: