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

Allow Lists, Maps, and Records to coexist in a Union #43

Merged
merged 1 commit into from
Feb 23, 2017

Conversation

tjaneczko
Copy link
Contributor

Currently, Lists, Maps, and Records cannot coexist in a Union because the $read method for these can throw TypeErrors rather than returning them. The Immutable.js List constructor will throw a TypeError when attempting to initialize a list with a non-array-type object, exiting the Union while loop prematurely (before it tests against the other types). This PR adds a try/catch around the $read and swallows any TypeErrors that come out of it. Other error types are thrown so they can be caught up the call stack.

Currently, Lists, Maps, and Records cannot coexist in a Union because the $read method for these can throw TypeErrors rather than returning them.  The Immutable.js List constructor will throw a TypeError when attempting to initialize a list with a non-array-type object, exiting the Union while loop prematurely (before it tests against the other types).  This PR adds a try/catch around the $read and swallows any TypeErrors that come out of it.  Other error types are thrown so they can be caught up the call stack.
@stutrek
Copy link
Member

stutrek commented Feb 16, 2017

👍 Good catch.

Let's merge after another set of eyes sees it.

@tjaneczko
Copy link
Contributor Author

Thanks! Let me know if you need me to do anything else to prep it for merging.

@stutrek stutrek merged commit c9a1cbf into typed-immutable:master Feb 23, 2017
@stutrek
Copy link
Member

stutrek commented Feb 23, 2017

Merged and published. Thanks!

@tjaneczko
Copy link
Contributor Author

Thanks @stutrek !

@tjaneczko tjaneczko deleted the union-list-map branch February 23, 2017 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants