Skip to content

Commit 6681a16

Browse files
committed
Remove object converter.
1 parent 3d98d22 commit 6681a16

File tree

1 file changed

+1
-68
lines changed

1 file changed

+1
-68
lines changed

jscomp/gentype/Converter.ml

+1-68
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ type t =
55
| CircularC of string * t
66
| FunctionC of functionC
77
| IdentC
8-
| ObjectC of fieldsC
98
| OptionC of t
109
| PromiseC of t
1110
| TupleC of t list
@@ -15,9 +14,6 @@ and groupedArgConverter =
1514
| ArgConverter of t
1615
| GroupConverter of (string * optional * t) list
1716

18-
and fieldC = {lblJS: string; lblRE: string; c: t}
19-
and fieldsC = fieldC list
20-
2117
and functionC = {
2218
funArgConverters: groupedArgConverter list;
2319
componentName: string option;
@@ -66,21 +62,6 @@ let rec toString converter =
6662
|> String.concat ", ")
6763
^ " -> " ^ toString retConverter ^ ")"
6864
| IdentC -> "id"
69-
| ObjectC fieldsC ->
70-
let dot =
71-
match converter with
72-
| ObjectC _ -> ". "
73-
| _ -> ""
74-
in
75-
"{" ^ dot
76-
^ (fieldsC
77-
|> List.map (fun {lblJS; lblRE; c} ->
78-
(match lblJS = lblRE with
79-
| true -> lblJS
80-
| false -> "(" ^ lblJS ^ "/" ^ lblRE ^ ")")
81-
^ ":" ^ (c |> toString))
82-
|> String.concat ", ")
83-
^ "}"
8465
| OptionC c -> "option(" ^ toString c ^ ")"
8566
| PromiseC c -> "promise(" ^ toString c ^ ")"
8667
| TupleC innerTypesC ->
@@ -191,27 +172,7 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface
191172
| Nullable t ->
192173
let tConverter, tNormalized = t |> visit ~visited in
193174
(OptionC tConverter, Nullable tNormalized)
194-
| Object (closedFlag, fields) ->
195-
let fieldsConverted =
196-
fields
197-
|> List.map (fun ({type_} as field) -> (field, type_ |> visit ~visited))
198-
in
199-
( ObjectC
200-
(fieldsConverted
201-
|> List.map (fun ({nameJS; optional}, (converter, _)) ->
202-
{
203-
lblJS = nameJS;
204-
lblRE = nameJS;
205-
c =
206-
(match optional = Mandatory with
207-
| true -> converter
208-
| false -> OptionC converter);
209-
})),
210-
Object
211-
( closedFlag,
212-
fieldsConverted
213-
|> List.map (fun (field, (_, tNormalized)) ->
214-
{field with type_ = tNormalized}) ) )
175+
| Object _ -> (IdentC, normalized_)
215176
| Option t ->
216177
let tConverter, tNormalized = t |> visit ~visited in
217178
(OptionC tConverter, Option tNormalized)
@@ -357,7 +318,6 @@ let rec converterIsIdentity ~config ~toJS converter =
357318
argConverter |> converterIsIdentity ~config ~toJS:(not toJS)
358319
| GroupConverter _ -> false)
359320
| IdentC -> true
360-
| ObjectC _ -> true
361321
| OptionC c -> c |> converterIsIdentity ~config ~toJS
362322
| PromiseC c -> c |> converterIsIdentity ~config ~toJS
363323
| TupleC innerTypesC ->
@@ -487,33 +447,6 @@ let rec apply ~config ~converter ~indent ~nameGen ~toJS ~variantTables value =
487447
EmitText.funDef ~bodyArgs ~functionName:componentName ~funParams ~indent
488448
~mkBody ~typeVars
489449
| IdentC -> value
490-
| ObjectC fieldsC ->
491-
let simplifyFieldConverted fieldConverter =
492-
match fieldConverter with
493-
| OptionC converter1 when converter1 |> converterIsIdentity ~config ~toJS
494-
->
495-
IdentC
496-
| _ -> fieldConverter
497-
in
498-
let fieldValues =
499-
fieldsC
500-
|> List.map (fun {lblJS; lblRE; c = fieldConverter} ->
501-
(match toJS with
502-
| true -> lblJS
503-
| false -> lblRE)
504-
^ ":"
505-
^ (value
506-
|> EmitText.fieldAccess
507-
~label:
508-
(match toJS with
509-
| true -> lblRE
510-
| false -> lblJS)
511-
|> apply ~config
512-
~converter:(fieldConverter |> simplifyFieldConverted)
513-
~indent ~nameGen ~toJS ~variantTables))
514-
|> String.concat ", "
515-
in
516-
"{" ^ fieldValues ^ "}"
517450
| OptionC c ->
518451
EmitText.parens
519452
[

0 commit comments

Comments
 (0)