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

Computation of intersection of multiple objects #54903

Closed
missannil opened this issue Jul 7, 2023 · 2 comments
Closed

Computation of intersection of multiple objects #54903

missannil opened this issue Jul 7, 2023 · 2 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@missannil
Copy link

Bug Report

🔎 Multiple objects intersection

🕗 5.1.3 and 5.1.6

⏯ Playground Link

Playground link with relevant code

💻 Code

type a = { a: string };

type b = { b: number };

type c = { a: number };

type d = { a: boolean };

type ComputeIntersection<O> = { [k in keyof O]: O[k] };

type test1 = ComputeIntersection<a & b>; 
// test1 =>  { a: string ; b:number}  That's what I expected

type test2 = ComputeIntersection<a & c>; 
// test2 => { a: never } ,That's what I expected. just like: test2 = { a: string & number }

type test3 = ComputeIntersection<a & c & d>;

// test3 = > never . This puzzles me,According to test2,  test3 is supposed to be "{ a: string & number & boolean}" The result is still "{ a:never }"

// Replace a & c with test2 .
type test4 = ComputeIntersection< test2 & d>;
// test4 => { a : never }. How do we understand this!

🙁 Actual behavior

type test3 = ComputeIntersection<a & c & d>;
// test3 => never

🙂 Expected behavior

type test3 = ComputeIntersection<a & c & d>;
// test3 = { a: never }

@jcalz
Copy link
Contributor

jcalz commented Jul 7, 2023

working as intended as per #36696

@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Jul 7, 2023
@typescript-bot
Copy link
Collaborator

This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

4 participants