Is there a way to check if some value is of JsAny ...
# webassembly
p
Is there a way to check if some value is of JsAny type? Naive
is JsAny
makes the compiler angry since it's an external type. My use case is writing a simple idempotent Any->JsAny converter which accepts primitives, iterables, maps and JsAny and gets me back JsAny or throws an error.
p
@Robert Jaros very interesting, thank you. I have a question though: function's comment says that all unsupported values are converted to
null
on wasmJs, but as far as I see the
else
block uses
cast()
, which is just an unsafe
this as T
cast on wasmJs. How would it produce
null
if I use something like
myDataClassInstance.toJsAny()
?
r
The comment is wrong 🙂 It wasn't updated when it should have been.
p
Ah, alright then 🙂 I guess it works the same as what I've ended up with. Anyway, thanks again, always interesting to see how people do utils for wasmJs.