Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Cover union types, type aliases, type guards #74

Merged
merged 10 commits into from
Dec 6, 2015

Conversation

DanielRosenwasser
Copy link
Member

Fixes #37 and partially addresses #35

@@ -0,0 +1,197 @@
# Introduction

TODO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me write one for you if that's okay:

When thinking about types, sometimes it is useful to think about operations on those types -- if we have something which is both a Fridge and a Toaster, how can we best describe this amalgamation?
Well, usually in the same way we just did -- as a Fridge & Toaster.
This kind of basic type arithmetic can be incredibly useful in being more expressive with your types, helping you say what you mean without jumping through classical inheritance-based hoops.
In TypeScript, we support three main productions which operate on types - [Unions](# Union Types), [Intersections](# Intersection Types), and [Aliases](# Type Aliases).
Supporting these we have [Type Guards](# Type Guards), boolean-returning functions meant to indicate to the typesystem weather an argument is to be considered of a narrowed type in a given branch of code.
Using these constructs correctly can enhance the semantic meaning of your types and help create a strongly typed, meaningful interface for your TypeScript program.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's pretty great, though, I'm not 100% certain we're going to have intersection types here; it would be appropriate though.

@DanielRosenwasser DanielRosenwasser changed the title Cover union types, type aliases Cover union types, type aliases, type guards Dec 4, 2015
DanielRosenwasser added a commit that referenced this pull request Dec 6, 2015
Cover union types, type aliases, type guards
@DanielRosenwasser DanielRosenwasser merged commit 2f8e8e8 into master Dec 6, 2015
@DanielRosenwasser DanielRosenwasser deleted the advancedTypes branch December 6, 2015 22:55
@DanielRosenwasser
Copy link
Member Author

@sandersn and @weswigham if you have feedback about recent changes, I'd be open to still making amendments.

@sandersn
Copy link
Member

sandersn commented Dec 7, 2015

I still don't like "It just so happens Typescript has type guards". 😣
That's the only thing -- the more recent changes look good.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants