Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-unused: false positive with substitution type inside mapped type #85

Open
ajafff opened this issue Jul 19, 2018 · 2 comments
Open

no-unused: false positive with substitution type inside mapped type #85

ajafff opened this issue Jul 19, 2018 · 2 comments
Labels

Comments

@ajafff
Copy link
Owner

ajafff commented Jul 19, 2018

type Values<T> = T extends {[K in keyof T]: infer U} ? U : never;

U is marked as unused but is actually referenced in the then branch of the conditional type

@InExtremaRes
Copy link

It's similar but not exactly the same:

type Foo<T> = T extends { new (a: infer A): any } ? A : never;

A is marked as unused.

We can make and indirection, though:

interface Baz<A> { new (a: A): any }
type Bar<T> = T extends Baz<infer A> ? A : never;

@ifiokjr
Copy link

ifiokjr commented Feb 5, 2019

I think in general it affects many inferred types.

/**
 * Pick the Nth Param for any function with the first parameter marked by the 0 index.
 */
export type NthParam<GFunction extends AnyFunction, GIndex extends number> = GFunction extends (
  ...args: infer GArgs // => Flagged as unused
) => any
  ? GArgs[GIndex]
  : never;

The linter warns me that GArgs is unused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants