File tree Expand file tree Collapse file tree 2 files changed +10
-36
lines changed Expand file tree Collapse file tree 2 files changed +10
-36
lines changed Original file line number Diff line number Diff line change @@ -122,37 +122,6 @@ impl Interface {
122122
123123 import scala.scalajs.js
124124
125- sealed trait Optional[+A] extends js.Object {{
126- val tag: String
127- val `val`: js.UndefOr[js.Object] = js.undefined
128- }}
129- object Optional {{
130- def some[A](value: A): Optional[A] = new Optional[A] {{
131- val tag: String = \" some\"
132- override val `val`: js.UndefOr[js.Object] = js.Object(value)
133- }}
134-
135- def none: Optional[Nothing] = new Optional[Nothing] {{
136- val tag: String = \" none\"
137- }}
138- }}
139-
140- sealed trait Result[+Ok, +Err] extends js.Object {{
141- val tag: String
142- val `val`: js.UndefOr[js.Object] = js.undefined
143- }}
144- object Result {{
145- def ok[Ok](value: Ok): Result[Ok, Nothing] = new Result[Ok, Nothing] {{
146- val tag: String = \" ok\"
147- override val `val`: js.UndefOr[js.Object] = js.Object(value)
148- }}
149-
150- def err[Err](value: Err): Result[Nothing, Err] = new Result[Nothing, Err] {{
151- val tag: String = \" err\"
152- override val `val`: js.UndefOr[js.Object] = js.Object(value)
153- }}
154- }}
155-
156125 {records}
157126
158127 {variants}
Original file line number Diff line number Diff line change @@ -81,19 +81,22 @@ impl Render for Variant {
8181 name : case_name,
8282 ty,
8383 } | {
84- let ( def_or_val, param_list, val) = if let Some ( ty) = ty {
84+ let ( def_or_val, param_list, val, type_tag ) = if let Some ( ty) = ty {
8585 (
8686 "def" ,
8787 format ! ( "(value: {ty})" ) ,
88- "override val `val`: js.UndefOr[js.Object] = js.Object(value)" ,
88+ "override val `val`: js.UndefOr[Type] = value" ,
89+ format ! ( "type Type = {ty}" ) ,
8990 )
9091 } else {
91- ( "val" , String :: new ( ) , "" )
92+ ( "val" , String :: new ( ) , "" , "type Type = Nothing" . to_owned ( ) )
9293 } ;
9394
9495 format ! (
9596 "
96- {def_or_val} {case_name}{param_list}: {name} = new {name} {{
97+ {def_or_val} {case_name}{param_list} = new {name} {{
98+ {type_tag}
99+
97100 val tag: String = \" {case_name}\"
98101 {val}
99102 }}
@@ -107,8 +110,10 @@ impl Render for Variant {
107110 Ok ( format ! (
108111 "
109112 sealed trait {name} extends js.Object {{ self =>
113+ type Type
114+
110115 val tag: String
111- val `val`: js.UndefOr[js.Object] = js.undefined
116+ val `val`: js.UndefOr[Type]
112117 }}
113118
114119 object {name} {{
You can’t perform that action at this time.
0 commit comments