Skip to content

Commit

Permalink
fix: type of pipeable stream to allow objects with keys (#854)
Browse files Browse the repository at this point in the history
* fix: type of pipeable stream to allow objects with keys

* fix: test
  • Loading branch information
anmonteiro authored Sep 5, 2024
1 parent fa71fa8 commit c07e413
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/ReactDOMServerNode.re
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ type options = {
progressiveChunkSize: option(int),
};

type pipeableStream = {
type pipeableStream('a) = {
/* Using empty object instead of Node.stream since Melange don't provide a binding to node's Stream (https://nodejs.org/api/stream.html) */
pipe: Js.t({.}) => unit,
pipe: Js.t({..} as 'a) => unit,
abort: unit => unit,
};

[@mel.module "react-dom/server"]
external renderToPipeableStream: (React.element, options) => pipeableStream =
external renderToPipeableStream:
(React.element, options) => pipeableStream('a) =
"renderToPipeableStream";

let renderToPipeableStream =
Expand Down
6 changes: 3 additions & 3 deletions src/ReactDOMServerNode.rei
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ type options = {
progressiveChunkSize: option(int),
};

type pipeableStream = {
type pipeableStream('a) = {
/* Using empty object instead of Node.stream since Melange don't provide a binding to node's Stream (https://nodejs.org/api/stream.html) */
pipe: Js.t({.}) => unit,
pipe: Js.t({..} as 'a) => unit,
abort: unit => unit,
};

Expand All @@ -45,4 +45,4 @@ let renderToPipeableStream:
~progressiveChunkSize: int=?,
React.element
) =>
pipeableStream;
pipeableStream('a);
2 changes: 1 addition & 1 deletion test/ReactDOM__test.re
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe("ReactDOM", () => {
hasErrored := true;
},
);
let {pipe, abort: _}: ReactDOMServerNode.pipeableStream =
let {pipe, abort: _}: ReactDOMServerNode.pipeableStream(_) =
ReactDOMServerNode.renderToPipeableStream(
<div> "Hello world!"->React.string </div>,
);
Expand Down

0 comments on commit c07e413

Please sign in to comment.