Skip to content

Commit 65fe259

Browse files
committed
Clean up unused Record and RecordC.
1 parent e4a26c8 commit 65fe259

File tree

5 files changed

+5
-67
lines changed

5 files changed

+5
-67
lines changed

jscomp/gentype/Converter.ml

+1-56
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ type t =
99
| ObjectC of fieldsC
1010
| OptionC of t
1111
| PromiseC of t
12-
| RecordC of fieldsC
1312
| TupleC of t list
1413
| VariantC of variantC
1514

@@ -69,7 +68,7 @@ let rec toString converter =
6968
^ " -> " ^ toString retConverter ^ ")"
7069
| IdentC -> "id"
7170
| NullableC c -> "nullable(" ^ toString c ^ ")"
72-
| ObjectC fieldsC | RecordC fieldsC ->
71+
| ObjectC fieldsC ->
7372
let dot =
7473
match converter with
7574
| ObjectC _ -> ". "
@@ -222,26 +221,6 @@ let typeGetConverterNormalized ~config ~inline ~lookupId ~typeNameIsInterface
222221
| Promise t ->
223222
let tConverter, tNormalized = t |> visit ~visited in
224223
(PromiseC tConverter, Promise tNormalized)
225-
| Record fields ->
226-
let fieldsConverted =
227-
fields
228-
|> List.map (fun ({type_} as field) -> (field, type_ |> visit ~visited))
229-
in
230-
( RecordC
231-
(fieldsConverted
232-
|> List.map (fun ({nameJS; nameRE; optional}, (converter, _)) ->
233-
{
234-
lblJS = nameJS;
235-
lblRE = nameRE;
236-
c =
237-
(match optional = Mandatory with
238-
| true -> converter
239-
| false -> OptionC converter);
240-
})),
241-
Record
242-
(fieldsConverted
243-
|> List.map (fun (field, (_, tNormalized)) ->
244-
{field with type_ = tNormalized})) )
245224
| Tuple innerTypes ->
246225
let innerConversions, normalizedList =
247226
innerTypes |> List.map (visit ~visited) |> List.split
@@ -395,7 +374,6 @@ let rec converterIsIdentity ~config ~toJS converter =
395374
| _ -> c |> converterIsIdentity ~config ~toJS)
396375
| OptionC c -> if toJS then c |> converterIsIdentity ~config ~toJS else false
397376
| PromiseC c -> c |> converterIsIdentity ~config ~toJS
398-
| RecordC _ -> false
399377
| TupleC innerTypesC ->
400378
innerTypesC |> List.for_all (converterIsIdentity ~config ~toJS)
401379
| VariantC {withPayloads; useVariantTables} ->
@@ -581,39 +559,6 @@ let rec apply ~config ~converter ~indent ~nameGen ~toJS ~variantTables value =
581559
^ ") { return "
582560
^ (x |> apply ~config ~converter:c ~indent ~nameGen ~toJS ~variantTables)
583561
^ "})"
584-
| RecordC fieldsC ->
585-
let simplifyFieldConverted fieldConverter =
586-
match fieldConverter with
587-
| OptionC converter1 when converter1 |> converterIsIdentity ~config ~toJS
588-
->
589-
IdentC
590-
| _ -> fieldConverter
591-
in
592-
if toJS then
593-
let fieldValues =
594-
fieldsC
595-
|> List.mapi (fun index {lblJS; c = fieldConverter} ->
596-
lblJS ^ ":"
597-
^ (value
598-
|> EmitText.arrayAccess ~index
599-
|> apply ~config
600-
~converter:(fieldConverter |> simplifyFieldConverted)
601-
~indent ~nameGen ~toJS ~variantTables))
602-
|> String.concat ", "
603-
in
604-
"{" ^ fieldValues ^ "}"
605-
else
606-
let fieldValues =
607-
fieldsC
608-
|> List.map (fun {lblJS; c = fieldConverter} ->
609-
value
610-
|> EmitText.fieldAccess ~label:lblJS
611-
|> apply ~config
612-
~converter:(fieldConverter |> simplifyFieldConverted)
613-
~indent ~nameGen ~toJS ~variantTables)
614-
|> String.concat ", "
615-
in
616-
"[" ^ fieldValues ^ "]"
617562
| TupleC innerTypesC ->
618563
"["
619564
^ (innerTypesC

jscomp/gentype/EmitJs.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ let typeNameIsInterface ~(exportTypeMap : CodeItem.exportTypeMap)
101101
~(exportTypeMapFromOtherFiles : CodeItem.exportTypeMap) typeName =
102102
let typeIsInterface type_ =
103103
match type_ with
104-
| Object _ | Record _ -> true
104+
| Object _ -> true
105105
| _ -> false
106106
in
107107
match exportTypeMap |> StringMap.find typeName with
@@ -624,7 +624,7 @@ let propagateAnnotationToSubTypes ~codeItems (typeMap : CodeItem.exportTypeMap)
624624
| Function {argTypes; retType} ->
625625
argTypes |> List.iter (fun {aType} -> visit aType);
626626
retType |> visit
627-
| GroupOfLabeledArgs fields | Object (_, fields) | Record fields ->
627+
| GroupOfLabeledArgs fields | Object (_, fields) ->
628628
fields |> List.iter (fun {type_} -> type_ |> visit)
629629
| Option t | Null t | Nullable t | Promise t | Undefined t -> t |> visit
630630
| Tuple innerTypes -> innerTypes |> List.iter visit

jscomp/gentype/EmitType.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ let rec renderType ~(config : Config.t) ?(indent = None) ~typeNameIsInterface
120120
| Function {argTypes; retType; typeVars} ->
121121
renderFunType ~config ~indent ~inFunType ~typeNameIsInterface ~typeVars
122122
argTypes retType
123-
| GroupOfLabeledArgs fields | Object (_, fields) | Record fields ->
123+
| GroupOfLabeledArgs fields | Object (_, fields) ->
124124
let indent1 = fields |> Indent.heuristicFields ~indent in
125125
fields
126126
|> renderFields ~config ~indent:indent1 ~inFunType ~typeNameIsInterface

jscomp/gentype/GenTypeCommon.ml

-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ type type_ =
6868
| Object of closedFlag * fields
6969
| Option of type_
7070
| Promise of type_
71-
| Record of fields
7271
| Tuple of type_ list
7372
| TypeVar of string
7473
| Undefined of type_
@@ -119,7 +118,6 @@ let typeIsObject type_ =
119118
| Object _ -> true
120119
| Option _ -> false
121120
| Promise _ -> true
122-
| Record _ -> true
123121
| Tuple _ -> true
124122
| TypeVar _ -> false
125123
| Undefined _ -> false

jscomp/gentype/TypeVars.ml

+1-6
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ let rec substitute ~f type0 =
5858
{field with type_ = field.type_ |> substitute ~f}) )
5959
| Option type_ -> Option (type_ |> substitute ~f)
6060
| Promise type_ -> Promise (type_ |> substitute ~f)
61-
| Record fields ->
62-
Record
63-
(fields
64-
|> List.map (fun field ->
65-
{field with type_ = field.type_ |> substitute ~f}))
6661
| Tuple innerTypes -> Tuple (innerTypes |> List.map (substitute ~f))
6762
| TypeVar s -> (
6863
match f s with
@@ -86,7 +81,7 @@ let rec free_ type0 : StringSet.t =
8681
StringSet.diff
8782
((argTypes |> freeOfList_) +++ (retType |> free_))
8883
(typeVars |> StringSet.of_list)
89-
| GroupOfLabeledArgs fields | Object (_, fields) | Record fields ->
84+
| GroupOfLabeledArgs fields | Object (_, fields) ->
9085
fields
9186
|> List.fold_left
9287
(fun s {type_} -> StringSet.union s (type_ |> free_))

0 commit comments

Comments
 (0)