Erased unions #660

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

Comments

Projects
None yet
1 participant
@Jand42
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

This comment has been minimized.

Show comment
Hide comment
@Jand42

Jand42 Feb 18, 2017

Member

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.

Member

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.

@Jand42 Jand42 closed this in 3bd452a Feb 18, 2017

Jand42 added a commit that referenced this issue Feb 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment