hallvard
02/27/2020, 2:38 PMSean Keane
02/27/2020, 2:43 PMactual var hello = "HELLO WORLD"
@JsName("testMap")
actual var testMap: Map<String, String> = mapOf(Pair("key", "JS"))
This is my map currentlyhallvard
02/27/2020, 2:46 PMhallvard
02/27/2020, 2:46 PMSean Keane
02/27/2020, 2:47 PMSean Keane
02/27/2020, 2:48 PM}(this, function (_, Kotlin) {
'use strict';
var Pair = Kotlin.kotlin.Pair;
var mapOf = Kotlin.kotlin.collections.mapOf_x2b85n$;
var hello;
var testMap;
hello = 'HELLO WORLD';
testMap = mapOf(new Pair('key', 'JS'));
}));
These vars cannot be accessedhallvard
02/27/2020, 3:03 PMSean Keane
02/27/2020, 3:04 PMSean Keane
02/27/2020, 4:17 PM@JsName("mapGetter")
fun mapGetter(map: Map<*, *>, key: Any): Any? {
return map[key]
}
And can access the fields like this.
common.mapGetter(common.testMap, "char") = "X"
common.mapGetter(common.testMapInt, 1) = 10
Sean Keane
02/27/2020, 4:27 PMSean Keane
02/27/2020, 4:31 PMIvan Kubyshkin [JetBrains]
02/28/2020, 7:20 AMSean Keane
02/28/2020, 8:10 AM"This is by design, to avoid name clashes on JavaScript when overriding methods. A "reproducible" suffix is generated based on the number and type of its parameterss and appended to the method name. This guarantees a unique JS method per Kotlin method.I'm not an expert but I don't think this there is anything to "fix" here. You can create your own "listOf" kind aliases in Kotlin and use @JsName annotation to force the name to be the same in the generated JS code." I'm a bit lost as to why the methods where not just named slightly different while this was getting addressed like "map.getFor("key")".