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

Conditional type unexpectedly non-distributive with never #57343

Closed
rotu opened this issue Feb 8, 2024 · 1 comment Β· Fixed by #57345
Closed

Conditional type unexpectedly non-distributive with never #57343

rotu opened this issue Feb 8, 2024 · 1 comment Β· Fixed by #57345
Assignees
Labels
Bug A bug in TypeScript

Comments

@rotu
Copy link

rotu commented Feb 8, 2024

πŸ”Ž Search Terms

never, intersection, contradiction

πŸ•— Version & Regression Information

⏯ Playground Link

Workbench Repro

πŸ’» Code

type IsNumber<T> = T extends number ? true : false

type Conflicted = {x:true} & {x:false} // never
//   ^?

type Ex1 = IsNumber<Conflicted> // true. Should be never 
//   ^?
type Ex2 = IsNumber<never>
//   ^?

// Conflicted starts behaving like `never` again when distributivity is forced by putting it in a union
type Ex3 = IsNumber<"OEEE" | Conflicted> // false (boolean in TypeScript 4.6.4)
//   ^?
type Ex4 = IsNumber<1 | Conflicted> // true
//   ^?

πŸ™ Actual behavior

Ex1 is true.

πŸ™‚ Expected behavior

IsNumber<Conflicted> should be never. This is a distributive conditional.

Additional information about the issue

This also manifests as ReturnType<T> being unknown when T is a conflicted intersection.

Originally submitted in #57210 which was overly broad.

@rotu rotu changed the title Conditional with nover Conditional type unexpectedly non-distributive with never Feb 8, 2024
@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Feb 8, 2024
@fatcerberus
Copy link

fatcerberus commented Feb 8, 2024

Possibly related to/same root cause as #57210?
edit: oh, you already said it was a do-over of 57210 in the OP, nevermind

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

Successfully merging a pull request may close this issue.

4 participants