Collection types in generated d.ts file

In my code, I export a function like this:

fun calculatePrice(
  position: FuturePosition,
  positionList: List<FuturePosition>,
  balanceList: List<FutureBalance>,
  bracketList: List<FutureBracket>,
): Double {

Although I got the following warning:
Exported declaration uses non-exportable parameter type: List<FuturePosition>

I’ve found that if I export List and ArrayList to Javascript, I can use them to create arguments for calculatePrice function. Here is my way to export List and ArrayList.

fun <E> KotlinArrayList(vararg elements: E): ArrayList<E> = arrayListOf(*elements)

fun <E> KotlinList(vararg elements: E): List<E> = listOf(*elements)

But in generated d.ts file, it seems we can’t find kotlin namespace, so their types are all any.

Is there any way I can get right type for collections or easier way to export List and ArrayList?

On exportable code in Kotlin/JS, I always use Array instead of List, they are natively supported in JS. Not ideal, I know, especially if you have to deal with those on the Kotlin side a lot, but it makes interoperability much better.

Another question, are you adding @JsExport on your other Future* classes? Those needed to be exported as well, as they are part of the public API of your exported function.

Yes, We also decide to use Array instead of List.
But in the future, we may use Map in our code. At that time this problem will occur again.
Is there any suggestions to integrate Map data?

And yes these Future* classes are all exported by @JsExport.

No, I have no suggestions for the Map issue. Maps in Java/Kotlin are very different from Objects in JS, so there is no 1:1 correlation.