Permalink
Browse files

fix: evaluateHandle return types

Return types were wrong for the eval functions in the
Evaluator.evaluateHandle family of functions. The eval function
should return some JS object and it's Puppeteer's job to convert
that to a handle. We had the user-provided eval function returning
a handle which they don't have a way of constructing. This was
missed because of using `%raw` for the eval function in the tests
with type annotations, so a wrong type was inferred.

While looking over this function set I also noticed that some had
the whole function's return type as `'r` rather than `JSHandle.t`.
We know for sure these all return a `JSHandle.t` or promise of one.
These types are also corrected.
  • Loading branch information...
zploskey committed Sep 11, 2018
1 parent 3682563 commit 370ca6e5463966520bc18a3ef36d4f21a0dfd3e8
Showing with 14 additions and 23 deletions.
  1. +14 −23 src/Evaluator.re
@@ -61,73 +61,64 @@ module Impl = (T: {type t;}) => {
external evaluateString: (T.t, string) => Js.Promise.t('r) = "evaluate";

[@bs.send]
external evaluateHandle:
(T.t, unit => JSHandle.t) => Js.Promise.t(JSHandle.t) =
"";
external evaluateHandle: (T.t, unit => 'r) => Js.Promise.t(JSHandle.t) = "";

[@bs.send]
external evaluateHandlePromise:
(T.t, unit => Js.Promise.t(JSHandle.t)) => Js.Promise.t(JSHandle.t) =
(T.t, unit => Js.Promise.t('r)) => Js.Promise.t(JSHandle.t) =
"";

[@bs.send]
external evaluateHandle1:
(T.t, [@bs.uncurry] ('a => JSHandle.t), 'a) => Js.Promise.t(JSHandle.t) =
(T.t, [@bs.uncurry] ('a => 'r), 'a) => Js.Promise.t(JSHandle.t) =
"evaluateHandle";

[@bs.send]
external evaluateHandlePromise1:
(T.t, [@bs.uncurry] ('a => Js.Promise.t(JSHandle.t)), 'a) =>
(T.t, [@bs.uncurry] ('a => Js.Promise.t('r)), 'a) =>
Js.Promise.t(JSHandle.t) =
"evaluateHandle";

[@bs.send]
external evaluateHandle2:
(T.t, [@bs.uncurry] (('a, 'b) => JSHandle.t), 'a, 'b) =>
Js.Promise.t(JSHandle.t) =
(T.t, [@bs.uncurry] (('a, 'b) => 'r), 'a, 'b) => Js.Promise.t(JSHandle.t) =
"evaluateHandle";

[@bs.send]
external evaluateHandlePromise2:
(T.t, [@bs.uncurry] (('a, 'b) => Js.Promise.t(JSHandle.t)), 'a, 'b) =>
(T.t, [@bs.uncurry] (('a, 'b) => Js.Promise.t('r)), 'a, 'b) =>
Js.Promise.t(JSHandle.t) =
"evaluateHandle";

[@bs.send]
external evaluateHandle3:
(T.t, [@bs.uncurry] (('a, 'b, 'c) => JSHandle.t), 'a, 'b, 'c) =>
Js.Promise.t('r) =
(T.t, [@bs.uncurry] (('a, 'b, 'c) => 'r), 'a, 'b, 'c) =>
Js.Promise.t(JSHandle.t) =
"evaluateHandle";

[@bs.send]
external evaluateHandlePromise3:
(
T.t,
[@bs.uncurry] (('a, 'b, 'c) => Js.Promise.t(JSHandle.t)),
'a,
'b,
'c
) =>
Js.Promise.t('r) =
(T.t, [@bs.uncurry] (('a, 'b, 'c) => Js.Promise.t('r)), 'a, 'b, 'c) =>
Js.Promise.t(JSHandle.t) =
"evaluateHandle";

[@bs.send]
external evaluateHandle4:
(T.t, [@bs.uncurry] (('a, 'b, 'c, 'd) => JSHandle.t), 'a, 'b, 'c, 'd) =>
Js.Promise.t('r) =
(T.t, [@bs.uncurry] (('a, 'b, 'c, 'd) => 'r), 'a, 'b, 'c, 'd) =>
Js.Promise.t(JSHandle.t) =
"evaluateHandle";

[@bs.send]
external evaluateHandlePromise4:
(
T.t,
[@bs.uncurry] (('a, 'b, 'c, 'd) => Js.Promise.t(JSHandle.t)),
[@bs.uncurry] (('a, 'b, 'c, 'd) => Js.Promise.t('r)),
'a,
'b,
'c,
'd
) =>
Js.Promise.t('r) =
Js.Promise.t(JSHandle.t) =
"evaluateHandle";

/**

0 comments on commit 370ca6e

Please sign in to comment.