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

IsAny not working with "any" as generic type argument under different constraint #947

Open
Xriuk opened this issue Aug 28, 2024 · 0 comments

Comments

@Xriuk
Copy link

Xriuk commented Aug 28, 2024

Reproduction

type Generic<Type extends string> = Type;
type GenericInstance = Generic<any>;


type T1 = GenericInstance extends Generic<infer T> ? T : never; // any
type T2 = IsAny<T1>; // true, as it should be

type T3 = GenericInstance extends Generic<infer T> ? IsAny<T> : never; // false, but should be true

// I guess the second inference removes references to the type being a string?
type T4 = GenericInstance extends Generic<infer T> ? IsAny<T extends (infer TT) ? TT : never> : never; // true, as it should be

My wild guess is that it has something to do with the generic constraint <Type extends string> and the returned any is still seen as some sort of string in this case, might be a TS bug?

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • The funding will be given to active contributors.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@Xriuk Xriuk changed the title IsAny not working with some generic types IsAny not working with "any" as generic type argument under different constraint Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant