Can someone tell me why we can’t export value classes to js? I can’t find any documentation on this.
I’m using kotlin multiplatform in my project with kotlin 1.8 and the new IR compiler.
If I annotate a value class, that is part of the commonMain with ‘@JsExport’ I receive this error:
“Declaration of such kind (value class) can’t be exported to JS”
@JvmInline
@JsExport
public value class MyValue(private val value: Long)
What would you expect to see on the JS side after exporting value class (previously known as inline class)? It’s only available from Kotlin code, it doesn’t exist after compilation, it’s replaced with whatever type it holds.
and use that instead of MyValue class. The methods would be declared somewhere globally with a hashed name, unless specified otherwise.
Because with this compilation approach, it would be possible to compile the value classes on the JVM as it currently is while the JS would have some kind of fallback.