In Kotlin Multiplatform library I'm using below Da...
# javascript
k
In Kotlin Multiplatform library I'm using below Data class and want exporting it for Typescript definition my github repo
Copy code
@JsExport
data class RequestConfig<T>(
    val urlPath: String,
    val resource: Any? = null,
    val postBodyJson: T? = null,
    val headerMap: Map<String, String> = emptyMap(),
    val postBody: Map<String, String> = emptyMap(),
)
Its complaining about Map not being exportable, although when I generate TS definition files it is as below. Its simply assigning HeaderMap and postBody type as
Any
. Is there any library I can convert that to Map in TS ?
Copy code
type Nullable<T> = T | null | undefined
export declare namespace com.demo.payments.data.config {
    class RequestConfig<T> {
        constructor(urlPath: string, resource?: Nullable<any>, postBodyJson?: Nullable<T>, headerMap?: any/* kotlin.collections.Map<string, string> */, postBody?: any/* kotlin.collections.Map<string, string> */);
        get urlPath(): string;
        get resource(): Nullable<any>;
        get postBodyJson(): Nullable<T>;
        get headerMap(): any/* kotlin.collections.Map<string, string> */;
        get postBody(): any/* kotlin.collections.Map<string, string> */;
        copy(urlPath?: string, resource?: Nullable<any>, postBodyJson?: Nullable<T>, headerMap?: any/* kotlin.collections.Map<string, string> */, postBody?: any/* kotlin.collections.Map<string, string> */): com.demo.payments.data.config.RequestConfig<T>;
        toString(): string;
        hashCode(): number;
        equals(other: Nullable<any>): boolean;
    }
}
When I look as Kotlin-Wrapper repo it has collection package (https://github.com/JetBrains/kotlin-wrappers/blob/master/kotlin-js/src/jsMain/kotlin/js/collections/JsMap.kt) Then I wonder why JS platform export dont support this.
a
Also, there is a branch for Kotlin/JS that contains such functionality, so, I hope, in some of the 2.0-Beta, it will be available for playing around.
k
@Artem Kobzar that’s good know !. Without the collections support it’s not worth the hassle for me (being a solo dev) to do extra effort of having this restriction.
1