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

Document discriminated unions #330

Merged
merged 5 commits into from
Jul 18, 2016
Merged

Document discriminated unions #330

merged 5 commits into from
Jul 18, 2016

Conversation

sandersn
Copy link
Member

Fixes #312

Also move intersection types together with union types.
Also some minor fixups.

Also move intersection types together with union types.
Also some minor fixups.
Squashed commit of the following:

commit a86ccc5d9170c7581a7cf63c8d60301ea450b96f
Merge: 620350d 819891d
Author: Nathan Shively-Sanders <nathansa@microsoft.com>
Date:   Mon Jun 27 10:56:02 2016 -0700

    Merge branch 'release-2.0' into discriminated-unions-WIP

commit 620350dcfc0fe0be8bed7dd6894f7436e45dc059
Author: Nathan Shively-Sanders <nathansa@microsoft.com>
Date:   Mon Jun 27 10:49:47 2016 -0700

    Finish exhaustiveness checking

commit e5fabc82df929a04cf0f695d8f5f7aead19106b3
Author: Nathan Shively-Sanders <nathansa@microsoft.com>
Date:   Mon Jun 27 10:04:01 2016 -0700

    Mostly done

commit 572e93a1a9bc956011e12add5c60c18de1712b57
Author: Nathan Shively-Sanders <nathansa@microsoft.com>
Date:   Mon Jun 27 09:31:56 2016 -0700

    One new example and minor wording tweaks

commit 87f684499ce7c72a1d2067dd90f2889ecd164ea3
Author: Nathan Shively-Sanders <nathansa@microsoft.com>
Date:   Fri Jun 24 16:09:49 2016 -0700

    Preparatory reorganisation

    1. Move intersection types to the beginning.
    2. Improve wording a little.
@sandersn
Copy link
Member Author

@DanielRosenwasser can you take a look?

@@ -32,7 +74,7 @@ let indentedString = padLeft("Hello world", true); // passes at compile time, fa
In traditional object-oriented code, we might abstract over the two types by creating a hierarchy of types.
While this is much more explicit, it's also a little bit overkill.
One of the nice things about the original version of `padLeft` was that we were able to just pass in primitives.
That meant that usage was simple and not overly verbose.
That meant that usage was simple and concise.
Copy link
Member

Choose a reason for hiding this comment

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

lol

Copy link
Member Author

Choose a reason for hiding this comment

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

Concision ftw!

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, looks like I'm Steve again.

@sandersn
Copy link
Member Author

sandersn commented Jul 7, 2016

@DanielRosenwasser now that I am back from vacation, can you take a look at the updated PR?

One important difference is that type aliases cannot be extended or implemented from (nor can they extend/implement other types).
One difference is that interfaces create a new name that is used everywhere.
Type aliases don't create a new name &mdash; for instance, error messages won't use the alias name.
In the code below, intellisense will show that `interfaced` requires and returns an `Interface`, but `aliased` will show object literal types.
Copy link
Member

@DanielRosenwasser DanielRosenwasser Jul 11, 2016

Choose a reason for hiding this comment

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

hovering over interfaced in an editor that shows types in tooltips will show that it returns an Interface, while hovering over aliased will show it returns object literal type.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@sandersn sandersn merged commit 0a667ce into release-2.0 Jul 18, 2016
@sandersn sandersn deleted the discriminated-unions branch July 18, 2016 22:13
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.

2 participants