Skip to content

in conditional type, type parameter T is inferred as X, but [X] extends [T] is false #43123

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

Closed
jcalz opened this issue Mar 7, 2021 · 0 comments · Fixed by #43888
Closed

in conditional type, type parameter T is inferred as X, but [X] extends [T] is false #43123

jcalz opened this issue Mar 7, 2021 · 0 comments · Fixed by #43888
Assignees
Labels
Bug A bug in TypeScript Domain: Conditional Types The issue relates to conditional types Fix Available A PR has been opened for this issue

Comments

@jcalz
Copy link
Contributor

jcalz commented Mar 7, 2021

Bug Report

🔎 Search Terms

conditional inference, tuple, never

🕗 Version & Regression Information

⏯ Playground Link

Playground link

💻 Code

type Hmm = [0] extends [infer T, any?] ?
    [T, [0] extends [T] ? true : false]
    : never

🙁 Actual behavior

Hmm is evaluated as [0, false]. Somehow T is inferred as 0, but [0] doesn't extend [T]?

🙂 Expected behavior

Hmm should be evaluated as [0, true] as it does in TS 4.1.5 and below.

This behavior was brought up in a Stack Overflow question asking why it happens; not sure if there's any actual use case for this.

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Mar 8, 2021
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.3.1 milestone Mar 8, 2021
@weswigham weswigham added Bug A bug in TypeScript Domain: Conditional Types The issue relates to conditional types and removed Needs Investigation This issue needs a team member to investigate its status. labels Apr 29, 2021
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Apr 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Conditional Types The issue relates to conditional types Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants