Skip to content

Generic inference does not work as expected #60933

New issue

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

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

Already on GitHub? # to your account

Closed
uriva opened this issue Jan 8, 2025 · 1 comment
Closed

Generic inference does not work as expected #60933

uriva opened this issue Jan 8, 2025 · 1 comment

Comments

@uriva
Copy link

uriva commented Jan 8, 2025

🔎 Search Terms

type GenericGeneric<S> = <T extends S>(x: T) => T;
type GenericNumber = <T extends number>(t: T) => T;
type ExpectedTrue = GenericNumber extends GenericGeneric<infer _> ? true : false;

I expect the last type to be true but it's false

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about generics

⏯ Playground Link

No response

💻 Code

type GenericGeneric<S> = <T extends S>(x: T) => T;
type GenericNumber = <T extends number>(t: T) => T;
type ExpectedTrue = GenericNumber extends GenericGeneric<infer _> ? true : false;

🙁 Actual behavior

it's false

🙂 Expected behavior

should be `true

Additional information about the issue

No response

@jcalz
Copy link
Contributor

jcalz commented Jan 8, 2025

The title is quite vague. The search terms and playground link are missing.

Looks like a duplicate of #41040

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

No branches or pull requests

2 participants