At first sight, it seems easy using kotlin collections from js. Because kotlin multiplatform and its libraries (kotlinx.collections, etc) generate shared libraries that are interoperable between both js and kotlin. If we call new ArrayList() from javascript code it will construct a MutableList that is interoperable with kotlin-multiplatform code but this mutableList will not be usable directly in the js code because of mangling. Indeed when creating mutableList from js it does generates this kind of object (mutablelist)
let mutableList = new kt.kotlin.collections.ArrayList(["first", "second", "third"]);
console.log("js mutable list: ", mutableList);
and this give me this following log:
So as you can see all properties have mangling (hd7ov6$_0) and sadly no getters. (Getters/Setters with good name are generated thanks @JsName("name"), and it seems to be the only way to avoid mangling on properties and functions name.
So I ask the community and the kotlin team, how can such mangling still be on MPP, and will it change thanks the IR compiler and the new 1.6.20 version that allows interfaces and enum js export?
Also, is there good workaround ? The only one I see is sadly to reimplement a MutableList based on ArrayList, but the array composed by ArrayList is private. And as some ArrayList implementations methods lose the private array reference, I can't have a reference array on the base class.
Hope someone can help with a proper way to avoid this mangling... Thanks;)