Hi. Isn't is possible to use `JsReadonlyMap` on th...
# javascript
f
Hi. Isn't is possible to use
JsReadonlyMap
on the public interface of a
JsExport
class? IDEA show the "Exported declaration uses non-exportable ...". I would assume that this type was created exactly for this interoperability purpose.
t
It was created for interop. At the same moment it what already exists in browser typings. Problems: 1. No possiblity to avoid duplication with existed
ReadonlyMap
2. Exported
ReadonlyMap
from Kotlin/JS will be broken, because of export limitations
f
Thanks. Not sure I understood the response. • My goal is exactly interop, namely consume KT from JS/TS. • How hours I expose a readonly map for JS/TS consumers
e
You mean like this?
Copy code
import kotlin.js.collections.JsReadonlyMap

@OptIn(ExperimentalJsCollectionsApi::class)
interface I {
    val map: JsReadonlyMap<String, String>
}

@JsExport
@OptIn(ExperimentalJsExport::class, ExperimentalJsCollectionsApi::class)
class C(override val map: JsReadonlyMap<String, String>) : I
f
Yes, similar to that.
Copy code
@JsExport
class SomeClass (...){
   val someProp: JsReadonlyMap<String, SomeExportableClass>
}
e
I don't see any warning here