I am trying to set fillStyle on a HTML Canvas using the new KotlinWASM.
If I pass a string - I get a compiler error. If I force it to Dynamic (to pass typing), I get the browser crashing say the passed value is opaque.
** Compile Error (when String is passed)**
file:///Development/wasmMandlebrot/src/wasmMain/kotlin/canvas.kt:9:42 Type mismatch: inferred type is String but Dynamic? was expected
Browser Error (when Dynamic is passed)
Uncaught (in promise) TypeError: WebAssembly objects are opaque
at org.w3c.dom.fillStyle_$external_prop_setter_-1690691820 (wasmMandlebrot-wasm.uninstantiated.mjs?c843:3322:1)
** The code **
In essence its a ctx.fillStyle = “rgb(r,g,b)”
Is this me, or is this just because I am playing with Alpha software?
A workaround would be to write a separate external function and use String type there directly. It could be a separate external interface member or a top-level function with `@JsFun(“code”):
@JsFun("x => x")
external fun stringToDynamic(x: String): Dynamic