In my code, I export a function like this:
@JsExport
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.
@JsExport
fun <E> KotlinArrayList(vararg elements: E): ArrayList<E> = arrayListOf(*elements)
@JsExport
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?