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

Commit 5d61a2b

Browse files
committed
Add support for primitives in interface files.
1 parent 8b37a6b commit 5d61a2b

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

reason-react-example/src/interop/MyBannerRe.re

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1-
/**
2-
* ReactJS used by ReasonReact
3-
* This component wraps a ReactJS one, so that ReasonReact components can consume it
4-
* Typing the myBanner.js component's output as a `reactClass`.
5-
*/
6-
[@genFlow]
7-
[@bs.module]
8-
external myBanner : ReasonReact.reactClass = "./MyBanner";
1+
/* The @genFlow annotation is ignored if there's also a .rei file */
2+
[@genFlow] [@bs.module]
3+
external myBanner: ReasonReact.reactClass = "./MyBanner";
94

105
[@bs.deriving abstract]
116
type jsProps = {
127
show: bool,
138
message: string,
149
};
1510

16-
/** This is like declaring a normal ReasonReact component's `make` function, except the body is a the interop hook wrapJsForReason */
11+
/* The @genFlow annotation is ignored if there's also a .rei file */
1712
[@genFlow]
1813
let make = (~show, ~message, children) =>
1914
ReasonReact.wrapJsForReason(
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[@genFlow] [@bs.module]
2+
external myBanner: ReasonReact.reactClass = "./MyBanner";
3+
4+
[@bs.deriving abstract]
5+
type jsProps = {
6+
show: bool,
7+
message: string,
8+
};
9+
10+
[@genFlow]
11+
let make:
12+
(~show: bool, ~message: string, 'a) =>
13+
ReasonReact.component(
14+
ReasonReact.stateless,
15+
ReasonReact.noRetainedProps,
16+
ReasonReact.actionless,
17+
);

src/GenFlowMain.re

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,16 @@ let translateSignatureItem =
113113
|> CodeItem.combineTranslations
114114

115115
| {Typedtree.sig_desc: Tsig_value(valueDescription), _} =>
116-
valueDescription
117-
|> CodeItem.translateSignatureValue(~language, ~propsTypeGen, ~moduleName)
116+
if (valueDescription.val_prim != []) {
117+
valueDescription |> CodeItem.translatePrimitive;
118+
} else {
119+
valueDescription
120+
|> CodeItem.translateSignatureValue(
121+
~language,
122+
~propsTypeGen,
123+
~moduleName,
124+
);
125+
}
118126

119127
| _ => {CodeItem.dependencies: [], CodeItem.codeItems: []}
120128
};

0 commit comments

Comments
 (0)