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

Erased unions #660

Closed
Jand42 opened this issue Feb 18, 2017 · 1 comment
Closed

Erased unions #660

Jand42 opened this issue Feb 18, 2017 · 1 comment

Comments

@Jand42
Copy link
Member

Jand42 commented Feb 18, 2017

Add TypeScript-like union types for JS interop. Currently JS value is translated to/from WS-style union objects at WS/JS boundaries automatically by inlines generated by WIG.

New types are inside namespace WebSharper.JavaScript named Union<_,_> ... (with generics up to 7, same as Choice). These are constructed and matched specially:

  • Construction just keeps the same value in JS
  • UnionCaseTest translates to a type test
Jand42 added a commit that referenced this issue Feb 18, 2017
Jand42 added a commit that referenced this issue Feb 18, 2017
@Jand42
Copy link
Member Author

Jand42 commented Feb 18, 2017

New types in WebSharper.JavaScript namespace: Optional<'T> and Union<'T1,...,'Tn> (with generics up to 7)
Conversion helpers: Optional.ofOption/toOption, Union.ofChoiceN/toChoiceN.
toChoiceN is testing types in order to find what Choice case it can convert to.

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

No branches or pull requests

1 participant