-
Notifications
You must be signed in to change notification settings - Fork 731
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
Union vs. intersection types #295
Comments
Good catch! unfortunately I can't change the notes since we've already recorded the course and can't allow the video and code to get out of sync. Definitely something to ensure we get right in the next version! |
Sure, that makes sense. Thank you! |
Wow.. Im here because I was like... this does not make sense hahah glad to find that Im not crazy. |
Actually I find typescript's naming of Union and Intersection types very confusing... I haven't yet found any good explanation of why they are named like that :c |
@paseaf You can think of types as sets of values. The type Now if you talk about how you can use those types then you get the opposite result. The properties that you can access on a union type is the intersection of the properties of the individual types. So |
@nyfarn That's exactly what I was missing! Thank you so much! I just realized it's another way to think of things. The Union and Intersection are operating on properties of the involved types, and the result are the properties of the result types. This post has also helped me after reading it for a few times. |
Is your feature request related to a problem? Please describe.
If I'm not mistaken, the Basics code example under "Intersection types" actually shows a union type and vice versa.
Cf. https://www.typescriptlang.org/docs/handbook/advanced-types.html
Describe the solution you'd like
The headings could be swapped.
Thank you for this great course.
The text was updated successfully, but these errors were encountered: