5
5
| CircularC of string * t
6
6
| FunctionC of functionC
7
7
| IdentC
8
- | NullableC of t
9
8
| ObjectC of fieldsC
10
9
| OptionC of t
11
10
| PromiseC of t
@@ -67,7 +66,6 @@ let rec toString converter =
67
66
|> String. concat " , " )
68
67
^ " -> " ^ toString retConverter ^ " )"
69
68
| IdentC -> " id"
70
- | NullableC c -> " nullable(" ^ toString c ^ " )"
71
69
| ObjectC fieldsC ->
72
70
let dot =
73
71
match converter with
@@ -119,8 +117,7 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface
119
117
| Array (t , mutable_ ) ->
120
118
let tConverter, tNormalized = t |> visit ~visited in
121
119
(ArrayC tConverter, Array (tNormalized, mutable_))
122
- | Dict _ ->
123
- (IdentC , normalized_)
120
+ | Dict _ -> (IdentC , normalized_)
124
121
| Function
125
122
({argTypes; componentName; retType; typeVars; uncurried} as function_)
126
123
->
@@ -190,10 +187,10 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface
190
187
else (IdentC , normalized_))
191
188
| Null t ->
192
189
let tConverter, tNormalized = t |> visit ~visited in
193
- (NullableC tConverter, Null tNormalized)
190
+ (OptionC tConverter, Null tNormalized)
194
191
| Nullable t ->
195
192
let tConverter, tNormalized = t |> visit ~visited in
196
- (NullableC tConverter, Nullable tNormalized)
193
+ (OptionC tConverter, Nullable tNormalized)
197
194
| Object (closedFlag , fields ) ->
198
195
let fieldsConverted =
199
196
fields
@@ -227,9 +224,6 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface
227
224
in
228
225
(TupleC innerConversions, Tuple normalizedList)
229
226
| TypeVar _ -> (IdentC , normalized_)
230
- | Undefined t ->
231
- let tConverter, tNormalized = t |> visit ~visited in
232
- (NullableC tConverter, Undefined tNormalized)
233
227
| Variant variant ->
234
228
let allowUnboxed = not variant.polymorphic in
235
229
let withPayloads, normalized, unboxed =
@@ -363,7 +357,6 @@ let rec converterIsIdentity ~config ~toJS converter =
363
357
argConverter |> converterIsIdentity ~config ~to JS:(not toJS)
364
358
| GroupConverter _ -> false )
365
359
| IdentC -> true
366
- | NullableC c -> c |> converterIsIdentity ~config ~to JS
367
360
| ObjectC fieldsC ->
368
361
fieldsC
369
362
|> List. for_all (fun {lblJS; lblRE; c} ->
@@ -372,7 +365,7 @@ let rec converterIsIdentity ~config ~toJS converter =
372
365
match c with
373
366
| OptionC c1 -> c1 |> converterIsIdentity ~config ~to JS
374
367
| _ -> c |> converterIsIdentity ~config ~to JS)
375
- | OptionC c -> if toJS then c |> converterIsIdentity ~config ~to JS else false
368
+ | OptionC c -> c |> converterIsIdentity ~config ~to JS
376
369
| PromiseC c -> c |> converterIsIdentity ~config ~to JS
377
370
| TupleC innerTypesC ->
378
371
innerTypesC |> List. for_all (converterIsIdentity ~config ~to JS)
@@ -501,13 +494,6 @@ let rec apply ~config ~converter ~indent ~nameGen ~toJS ~variantTables value =
501
494
EmitText. funDef ~body Args ~function Name:componentName ~fun Params ~indent
502
495
~mk Body ~type Vars
503
496
| IdentC -> value
504
- | NullableC c ->
505
- EmitText. parens
506
- [
507
- value ^ " == null ? " ^ value ^ " : "
508
- ^ (value
509
- |> apply ~config ~converter: c ~indent ~name Gen ~to JS ~variant Tables);
510
- ]
511
497
| ObjectC fieldsC ->
512
498
let simplifyFieldConverted fieldConverter =
513
499
match fieldConverter with
@@ -536,22 +522,12 @@ let rec apply ~config ~converter ~indent ~nameGen ~toJS ~variantTables value =
536
522
in
537
523
" {" ^ fieldValues ^ " }"
538
524
| OptionC c ->
539
- if toJS then
540
- EmitText. parens
541
- [
542
- value ^ " == null ? " ^ value ^ " : "
543
- ^ (value
544
- |> apply ~config ~converter: c ~indent ~name Gen ~to JS ~variant Tables
545
- );
546
- ]
547
- else
548
- EmitText. parens
549
- [
550
- value ^ " == null ? undefined : "
551
- ^ (value
552
- |> apply ~config ~converter: c ~indent ~name Gen ~to JS ~variant Tables
553
- );
554
- ]
525
+ EmitText. parens
526
+ [
527
+ value ^ " == null ? " ^ value ^ " : "
528
+ ^ (value
529
+ |> apply ~config ~converter: c ~indent ~name Gen ~to JS ~variant Tables);
530
+ ]
555
531
| PromiseC c ->
556
532
let x = " $promise" |> EmitText. name ~name Gen in
557
533
value ^ " .then(function _element("
0 commit comments