Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
dce
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoc committed Jun 1, 2021
1 parent 4bde041 commit 36b2516
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 56 deletions.
3 changes: 0 additions & 3 deletions src/Config_.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ type bsVersion = int * int * int
type config = {
bsCurryPath : string option;
bsDependencies : string list;
mutable emitFlowAny : bool;
mutable emitImportCurry : bool;
mutable emitImportPropTypes : bool;
mutable emitImportReact : bool;
Expand All @@ -36,7 +35,6 @@ let default =
{
bsCurryPath = None;
bsDependencies = [];
emitFlowAny = false;
emitImportCurry = false;
emitImportPropTypes = false;
emitImportReact = false;
Expand Down Expand Up @@ -238,7 +236,6 @@ let readConfig ~bsVersion ~getBsConfigFile ~namespace =
bsCurryPath;
bsDependencies;
suffix;
emitFlowAny = false;
emitImportCurry = false;
emitImportPropTypes = false;
emitImportReact = false;
Expand Down
3 changes: 1 addition & 2 deletions src/EmitJs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ let rec emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName
type t = {
propsType : type_;
resolvedTypeName : ResolvedName.t;
retType : type_;
typeVars : string list;
}
end in
Expand Down Expand Up @@ -281,7 +280,7 @@ let rec emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName
else ResolvedName.fromString name |> ResolvedName.dot "Props"
in
( Function {function_ with componentName = Some hookName},
Some {HookType.propsType; resolvedTypeName; retType; typeVars} )
Some {HookType.propsType; resolvedTypeName; typeVars} )
| _ -> (type_, None)
in

Expand Down
35 changes: 0 additions & 35 deletions src/EmitType.ml
Original file line number Diff line number Diff line change
Expand Up @@ -373,41 +373,6 @@ let require ~early =
let emitImportReact ~emitters =
"import * as React from 'react';" |> require ~early:true ~emitters
let emitPropTypes ~config ~emitters ~indent ~name fields =
let indent1 = indent |> Indent.more in
let prefix s = "PropTypes." ^ s in
let rec emitType ~indent (type_ : type_) =
match type_ with
| Array (t, _) -> prefix "arrayOf" ^ "(" ^ (t |> emitType ~indent) ^ ")"
| Ident {name = ("bool" | "number" | "string") as id} -> id |> prefix
| Function _ -> "func" |> prefix
| GroupOfLabeledArgs fields | Object (_, fields) | Record fields ->
let indent1 = indent |> Indent.more in
prefix "shape" ^ "({"
^ Indent.break ~indent:indent1
^ (fields
|> List.filter (fun ({nameJS} : field) -> nameJS <> "children")
|> List.map (emitField ~indent:indent1)
|> String.concat ("," ^ Indent.break ~indent:indent1))
^ Indent.break ~indent ^ "})"
| Ident _ | Null _ | Nullable _ | Option _ | Promise _ | Tuple _ | TypeVar _
| Variant _ ->
"any" |> prefix
and emitField ~indent ({nameJS; optional; type_} : field) =
nameJS ^ " : "
^ (type_ |> emitType ~indent)
^ match optional = Mandatory with true -> ".isRequired" | false -> ""
in
config.emitImportPropTypes <- true;
name ^ ".propTypes = " ^ "{"
^ Indent.break ~indent:indent1
^ (fields
|> List.filter (fun ({nameJS} : field) -> nameJS <> "children")
|> List.map (emitField ~indent:indent1)
|> String.concat ("," ^ Indent.break ~indent:indent1))
^ Indent.break ~indent ^ "};"
|> Emitters.export ~emitters
let emitImportTypeAs ~emitters ~config ~typeName ~asTypeName
~typeNameIsInterface ~importPath =
let typeName = sanitizeTypeName typeName in
Expand Down
8 changes: 0 additions & 8 deletions src/EmitType.mli
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ val emitImportValueAsEarly :
ImportPath.t ->
Emitters.t

val emitPropTypes :
config:config ->
emitters:Emitters.t ->
indent:Indent.t ->
name:string ->
field list ->
Emitters.t

val emitRequire :
importedValueOrComponent:bool ->
early:bool ->
Expand Down
2 changes: 0 additions & 2 deletions src/ImportPath.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ type t = string * string

let propTypes = ("", "prop-types")

let react = ("", "react")

let bsCurryPath ~config = ("", Config_.getBsCurryPath ~config)

let fromModule ~dir ~importExtension moduleName =
Expand Down
2 changes: 0 additions & 2 deletions src/ImportPath.mli
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@ val fromStringUnsafe : string -> t

val propTypes : t

val react : t

val toCmt : config:config -> outputFileRelative:string -> t -> string
2 changes: 0 additions & 2 deletions src/ModuleName.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ let curry = "Curry"

let propTypes = "PropTypes"

let react = "React"

let reasonPervasives = "ReasonPervasives"

let dotRegex = "." |> Str.quote |> Str.regexp
Expand Down
2 changes: 0 additions & 2 deletions src/ModuleName.mli
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ val fromStringUnsafe : string -> t

val propTypes : t

val react : t

val reasonPervasives : t

val toString : t -> string
Expand Down

0 comments on commit 36b2516

Please sign in to comment.