https://kotlinlang.org logo
#webassembly
Title
# webassembly
m

mbonnin

12/02/2023, 4:15 PM
Does
@JsExport
work in wasm? If yes, could the
JsAny
bound of
unsafeCast
be removed (source)? Reason is I have
@JsExport
classes that I want to unsafe cast in common code and I don't have
JsAny
available in
commonMain
. Or is there another way?
a

andylamax

12/02/2023, 7:29 PM
m

mbonnin

12/02/2023, 7:30 PM
Welp, that settles it, thanks!
s

Svyatoslav Kuzmich [JB]

12/03/2023, 8:58 AM
@JsExports
currently does work for package-level functions, but classes are not supported yet.
unsafeCast
upper bound will likely remain because we can’t unsafely cast Wasm values, while we can easily do this with JS values (they don’t care about static types).
thank you color 1
a

andylamax

12/03/2023, 8:59 AM
Shouldn't we introduce a different annotation WasmExport??
👀 1
Coz sometimes, I'd want to export my Js definition but no need to export my Typescript one. And I wan't to do all this from common code.
s

Svyatoslav Kuzmich [JB]

12/03/2023, 9:04 AM
We have @WasmExport/@WasmImport pair, but they are a bit different. They used for exporting and importing raw functions to/from other .wasm modules instead of adapting values for JS.
I understand and agree with @andylamax use-case, JsExport shouldn’t apply additional restrictions for K/JS when used in common code. We remember it, but haven’t managed to fix it yet.
👍 1
m

mbonnin

12/03/2023, 9:10 AM
Thanks a lot for the details!
a

andylamax

12/03/2023, 12:16 PM
Thanks a lot @Svyatoslav Kuzmich [JB]
2 Views