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

Commit

Permalink
rebase on master
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoc committed Jul 6, 2022
1 parent 5990f81 commit 799c60a
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/typescript-react-example/src/Records.gen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Curry: any = Curry__Es6Import;
import * as RecordsBS__Es6Import from './Records.bs';
const RecordsBS: any = RecordsBS__Es6Import;

import type {list} from '../src/shims/RescriptPervasives.shim';
import type {list} from './ReasonPervasives.gen';

// tslint:disable-next-line:interface-over-type-literal
export type coord = {
Expand Down
2 changes: 1 addition & 1 deletion examples/typescript-react-example/src/nested/Types.gen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {Json_t as Js_Json_t} from '../../src/shims/Js.shim';

import type {M_t__ as TypeNameSanitize_M_t__} from '../../src/TypeNameSanitize.gen';

import type {list} from '../../src/shims/RescriptPervasives.shim';
import type {list} from './ReasonPervasives.gen';

import type {t_ as TypeNameSanitize_t_} from '../../src/TypeNameSanitize.gen';

Expand Down
11 changes: 4 additions & 7 deletions src/EmitJs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ let rec emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName
let type_ =
match type_ with
| Function
({argTypes = [{aType = Object (_, fields)}]; retType} as function_)
({argTypes = [{aType = Object (closedFlag, fields); aName}]; retType} as function_)
when retType |> EmitType.isTypeFunctionComponent ~fields ->
let componentName =
match importFile with "." | ".." -> None | _ -> Some importFile
Expand All @@ -166,16 +166,13 @@ let rec emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName
|> List.map (fun (field : field) ->
match
field.nameJS = "children"
&& field.type_ |> EmitType.isTypeReactElement ~config
&& field.type_ |> EmitType.isTypeReactElement
with
| true -> {field with type_ = EmitType.typeReactChild ~config}
| true -> {field with type_ = EmitType.typeReactChild}
| false -> field)
in
let function_ =
{
function_ with
argTypes = [{argType with aType = Object (closedFlag, fields)}];
}
{function_ with argTypes = [{aType = Object (closedFlag, fields); aName}]}
in
Function {function_ with componentName}
| _ -> type_
Expand Down
2 changes: 1 addition & 1 deletion src/EmitType.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
open GenTypeCommon

let fileHeader ~config ~sourceFile =
let fileHeader ~sourceFile =
let makeHeader ~lines =
match lines with
| [line] -> "/* " ^ line ^ " */\n"
Expand Down
2 changes: 1 addition & 1 deletion src/GenTypeMain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ let emitTranslation ~config ~fileName ~outputFile ~outputFileRelative ~resolver
in
let fileContents =
signFile
(EmitType.fileHeader ~config ~sourceFile:(Filename.basename sourceFile)
(EmitType.fileHeader ~sourceFile:(Filename.basename sourceFile)
^ "\n" ^ codeText ^ "\n")
in
GeneratedFiles.writeFileIfRequired ~outputFile ~fileContents
Expand Down
2 changes: 1 addition & 1 deletion src/ModuleName.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let curry = "Curry"

let propTypes = "PropTypes"

let reasonPervasives = "ReasonPervasives"
let rescriptPervasives = "ReasonPervasives"

let dotRegex = "." |> Str.quote |> Str.regexp

Expand Down
2 changes: 1 addition & 1 deletion src/ModuleName.mli
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ val fromStringUnsafe : string -> t

val propTypes : t

val reasonPervasives : t
val rescriptPervasives : t

val toString : t -> string

Expand Down
3 changes: 1 addition & 2 deletions src/TranslateCoreType.ml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ and translateCoreType_ ~config ~typeVarsGen
|> List.map (fun (_, _, {dependencies}) -> dependencies)
|> List.concat)
in
{dependencies; type_}
| _ -> {dependencies = []; type_ = unknown})
{dependencies; type_})
| Ttyp_package {pack_path; pack_fields} -> (
match typeEnv |> TypeEnv.lookupModuleTypeSignature ~path:pack_path with
| Some (signature, typeEnv) ->
Expand Down
4 changes: 2 additions & 2 deletions src/TranslateTypeExprFromTypes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ let translateConstr ~config ~paramsTranslation ~(path : Path.t) ~typeEnv =
type_ = EmitType.typeReactRef ~type_:paramTranslation.type_;
}
| (["ReactDOM"; "domRef"] | ["ReactDOM"; "Ref"; "t"]), [] ->
{dependencies = []; type_ = EmitType.typeReactRef}
{dependencies = []; type_ = EmitType.typeReactDOMReDomRef}
| ["ReactDOM"; "Ref"; "currentDomRef"], [] ->
{dependencies = []; type_ = EmitType.typeAny ~config}
{dependencies = []; type_ = EmitType.typeAny}
| ["ReactDOMRe"; "domRef"], [] ->
{dependencies = []; type_ = EmitType.typeReactDOMReDomRef}
| ["ReactDOMRe"; "Ref"; "currentDomRef"], [] ->
Expand Down

0 comments on commit 799c60a

Please sign in to comment.