You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building for Embedded Swift, JSValue and JSObject don’t support JS function calls with more than 2 arguments. I noticed this when trying to call the fillRect() method on CanvasRenderingContext2D. Example:
import JavaScriptKit
letdocument=JSObject.global.document
letcanvas= document.getElementById("canvas")varctx:JSValue= canvas.getContext("2d")
// 🔴 Error (in Embedded Swift only): cannot call value of non-function type 'JSValue'
_ = ctx.fillRect(20,20,200,100)
Embedded Swift doesn't support existentials, so the general function invocation mechanism of the form subscript(dynamicMember name: String) -> ((ConvertibleToJSValue...) -> JSValue) is not available.
Both JSValue and JSObject only have concrete overloads for up to 2 function call arguments:
Question: Would you be interested in a PR that adds more of these concrete overloads for Embedded Swift? Or do you want to wait for variadic generics support in Embedded Swift to solve this problem "the right way"?
If it's the former, I'm willing to send the PR. In this case, up to how many arguments should I go? Is 4 enough? Or should we go up to, say, 6?
The text was updated successfully, but these errors were encountered:
When building for Embedded Swift,
JSValue
andJSObject
don’t support JS function calls with more than 2 arguments. I noticed this when trying to call thefillRect()
method onCanvasRenderingContext2D
. Example:The following works as a workaround but is ugly:
The reason that it doesn't work is:
Embedded Swift doesn't support existentials, so the general function invocation mechanism of the form
subscript(dynamicMember name: String) -> ((ConvertibleToJSValue...) -> JSValue)
is not available.Both
JSValue
andJSObject
only have concrete overloads for up to 2 function call arguments:Question: Would you be interested in a PR that adds more of these concrete overloads for Embedded Swift? Or do you want to wait for variadic generics support in Embedded Swift to solve this problem "the right way"?
If it's the former, I'm willing to send the PR. In this case, up to how many arguments should I go? Is 4 enough? Or should we go up to, say, 6?
The text was updated successfully, but these errors were encountered: