As far as I can tell, there's no reason for the type parameter of JsFunction to be T: Object, but should be T: This instead. The only place where the type parameter is used is for the call and construct methods, which I believe should be able to work with any This-compatible type. We also probably need to think carefully through all the ways a JsFunction<T> could be invoked, to make sure that there are no safety violations where we're declaring to the type system that this is for sure a T.
If I'm wrong about any of this, we should document why -- at the very least in comments.
As far as I can tell, there's no reason for the type parameter of
JsFunction
to beT: Object
, but should beT: This
instead. The only place where the type parameter is used is for thecall
andconstruct
methods, which I believe should be able to work with anyThis
-compatible type. We also probably need to think carefully through all the ways aJsFunction<T>
could be invoked, to make sure that there are no safety violations where we're declaring to the type system thatthis
is for sure aT
.If I'm wrong about any of this, we should document why -- at the very least in comments.