andylamax
02/04/2022, 12:01 AMlouiscad
02/04/2022, 11:48 AMandylamax
02/04/2022, 3:41 PM@JsExport
like
interface Animal {
fun makeSound(): String
}
An then I have implementations like
class DomesticAnimal : Animal()
class WildAnimal : Animal()
I have objects that expose these interfaces like
@file:JsExport
class Farm(val animals: Array<Animal>)
fun makeFarm():Farm {
// . . .
}
All of this is bundle into a javascript library to be consumed by the frontend devs
Problem
import SDK from 'lib'
const farm = SDK.makeFarm() // returns a Farm object even types from .d.ts are resolved
const animals = farm.animals // returns an array of mangled Animal objects.
At this point the properties of the contents of the array are mangled. The funny thing is, in this toy example, I failed to reproduce this, no object was mangled, but in our very large application, they appear to be mangled.
I tried exporting and not exporting implementations. This did not make any difference in the reproducer all objects came out unmagled, but in our large application they are still mangled even when the classes are exported or not. In short exporting doesn't even make a difference there as well.
Wish
I wish that I could just export the interfaces and don't really care about the implementation details, this seems to be possible in my reproducer but it seems like it is not consistent, Hence I can't even report it welllouiscad
02/05/2022, 12:04 AMandylamax
02/09/2022, 5:10 PMlouiscad
02/09/2022, 5:15 PM