# webassembly

Robert Jaros

09/24/2023, 6:37 PM
JS interop question. I can't use external function with array parameter like this
external fun init(modules: Array<JsAny>): Unit
, because array types are not supported. But I can use
external fun init(modules: JsArray<JsAny>): Unit
and create JsArray with the following "trick" (see thread).
I've defined my own plain JS module with this JS function:
Copy code
function jsArrayOf() {
    return arguments

export {jsArrayOf};
Then I've declared Kotlin external function:
Copy code

external fun jsArrayOf(vararg obj: JsAny): JsArray<JsAny>
And now I can use my external
function with an array parameter:
Copy code
init(jsArrayOf(..., ..., ...))
And it works fine. So why the compiler can't make the same trick and allow array parameters to external functions?
👍🏻 1