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

Bug with conditional types and constraints #23843

Closed
SimonMeskens opened this issue May 2, 2018 · 2 comments · Fixed by #29338
Closed

Bug with conditional types and constraints #23843

SimonMeskens opened this issue May 2, 2018 · 2 comments · Fixed by #29338
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@SimonMeskens
Copy link

SimonMeskens commented May 2, 2018

type Weird = (<U extends boolean>(a: U) => never) extends 
    (<U extends true>(a: U) => never) ? never : never;

This type puts the type checker in some sort of weird state where it's never narrowed into anything useful. I assume the proper type should be boolean never.

@jcalz
Copy link
Contributor

jcalz commented May 2, 2018

the proper type should be boolean

boolean? Or never?

@SimonMeskens
Copy link
Author

Sorry, yes, never, I changed the code slightly just before posting to try and demonstrate the bug better. I'll adjust the OP.

type Weird = (<U extends boolean>(a: U) => U) extends 
    (<U extends true>(a: U) => infer T) ? T : never;

This was the original code, in which case the answer is boolean, but it confuses the issue, because the problem is due to the contraints, not due to anything to do with return types or infer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants