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
@@ -68,7 +67,6 @@ let rec toString converter =
68
67
|> String. concat " , " )
69
68
^ " -> " ^ toString retConverter ^ " )"
70
69
| IdentC -> " id"
71
- | NullableC c -> " nullable(" ^ toString c ^ " )"
72
70
| ObjectC fieldsC | RecordC fieldsC ->
73
71
let dot =
74
72
match converter with
@@ -120,8 +118,7 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface
120
118
| Array (t , mutable_ ) ->
121
119
let tConverter, tNormalized = t |> visit ~visited in
122
120
(ArrayC tConverter, Array (tNormalized, mutable_))
123
- | Dict _ ->
124
- (IdentC , normalized_)
121
+ | Dict _ -> (IdentC , normalized_)
125
122
| Function
126
123
({argTypes; componentName; retType; typeVars; uncurried} as function_)
127
124
->
@@ -191,10 +188,10 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface
191
188
else (IdentC , normalized_))
192
189
| Null t ->
193
190
let tConverter, tNormalized = t |> visit ~visited in
194
- (NullableC tConverter, Null tNormalized)
191
+ (OptionC tConverter, Null tNormalized)
195
192
| Nullable t ->
196
193
let tConverter, tNormalized = t |> visit ~visited in
197
- (NullableC tConverter, Nullable tNormalized)
194
+ (OptionC tConverter, Nullable tNormalized)
198
195
| Object (closedFlag , fields ) ->
199
196
let fieldsConverted =
200
197
fields
@@ -248,9 +245,6 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface
248
245
in
249
246
(TupleC innerConversions, Tuple normalizedList)
250
247
| TypeVar _ -> (IdentC , normalized_)
251
- | Undefined t ->
252
- let tConverter, tNormalized = t |> visit ~visited in
253
- (NullableC tConverter, Undefined tNormalized)
254
248
| Variant variant ->
255
249
let allowUnboxed = not variant.polymorphic in
256
250
let withPayloads, normalized, unboxed =
@@ -384,7 +378,6 @@ let rec converterIsIdentity ~config ~toJS converter =
384
378
argConverter |> converterIsIdentity ~config ~to JS:(not toJS)
385
379
| GroupConverter _ -> false )
386
380
| IdentC -> true
387
- | NullableC c -> c |> converterIsIdentity ~config ~to JS
388
381
| ObjectC fieldsC ->
389
382
fieldsC
390
383
|> List. for_all (fun {lblJS; lblRE; c} ->
@@ -393,7 +386,7 @@ let rec converterIsIdentity ~config ~toJS converter =
393
386
match c with
394
387
| OptionC c1 -> c1 |> converterIsIdentity ~config ~to JS
395
388
| _ -> c |> converterIsIdentity ~config ~to JS)
396
- | OptionC c -> if toJS then c |> converterIsIdentity ~config ~to JS else false
389
+ | OptionC c -> c |> converterIsIdentity ~config ~to JS
397
390
| PromiseC c -> c |> converterIsIdentity ~config ~to JS
398
391
| RecordC _ -> false
399
392
| TupleC innerTypesC ->
@@ -523,13 +516,6 @@ let rec apply ~config ~converter ~indent ~nameGen ~toJS ~variantTables value =
523
516
EmitText. funDef ~body Args ~function Name:componentName ~fun Params ~indent
524
517
~mk Body ~type Vars
525
518
| IdentC -> value
526
- | NullableC c ->
527
- EmitText. parens
528
- [
529
- value ^ " == null ? " ^ value ^ " : "
530
- ^ (value
531
- |> apply ~config ~converter: c ~indent ~name Gen ~to JS ~variant Tables);
532
- ]
533
519
| ObjectC fieldsC ->
534
520
let simplifyFieldConverted fieldConverter =
535
521
match fieldConverter with
@@ -558,22 +544,12 @@ let rec apply ~config ~converter ~indent ~nameGen ~toJS ~variantTables value =
558
544
in
559
545
" {" ^ fieldValues ^ " }"
560
546
| OptionC c ->
561
- if toJS then
562
- EmitText. parens
563
- [
564
- value ^ " == null ? " ^ value ^ " : "
565
- ^ (value
566
- |> apply ~config ~converter: c ~indent ~name Gen ~to JS ~variant Tables
567
- );
568
- ]
569
- else
570
- EmitText. parens
571
- [
572
- value ^ " == null ? undefined : "
573
- ^ (value
574
- |> apply ~config ~converter: c ~indent ~name Gen ~to JS ~variant Tables
575
- );
576
- ]
547
+ EmitText. parens
548
+ [
549
+ value ^ " == null ? " ^ value ^ " : "
550
+ ^ (value
551
+ |> apply ~config ~converter: c ~indent ~name Gen ~to JS ~variant Tables);
552
+ ]
577
553
| PromiseC c ->
578
554
let x = " $promise" |> EmitText. name ~name Gen in
579
555
value ^ " .then(function _element("
0 commit comments