Edoardo Luppi
07/08/2026, 7:52 AM@JsExport data classes, as effectively they're just convenient in Kotlin.
What you end with is a TS declaration with:
copy(positional args)
toString()
hashCode()
equals(other)
• copy makes little sense imo as it is not ergonomic to use, not one bit
• toString good
• hashCode dubious about its usefulness in JS/TS
• equals good
My 2c is copy and hashCode make little sense in being exported, at least by default.
Looking for feedback here. I'm curious about other people's opinion.Artem Kobzar
07/08/2026, 9:29 AMcomponentN functions, so maybe we can think about those as well. I also remember one of the nice suggestions to export a TS-friendly overload for copy , so it will accept an anonymous JS-object (since copy is powerful as a combination of default arguments and named parameters features). So, it could be look like this:
// Kotlin
@JsExport
data class User(val name: String, val age: Int)
// TypeScript
const user = new User("George", 23);
const copy = user.copy({ age: 24 });
Regarding the hashCode also true, but I just afraid that there is a small group of people who needs such a feature (I just need to understand if there is and their use case)CLOVIS
07/08/2026, 9:52 AMequals and hashCode have a very similar contract, I think it would be strange to export one and not the other, even if they are not necessarily usefulCLOVIS
07/08/2026, 9:52 AMcopy({ age: 24 }) export, that seems useful and idiomaticEdoardo Luppi
07/08/2026, 9:56 AM@JsExport.Default and @JsExport.Ignore, what about something like @JsExport.DataClass(copy = false, hashCode = false, ...).
Now, the name is bad. But I guess you get where I want to go.Edoardo Luppi
07/08/2026, 9:58 AMcopy ends up being more ergonomic, then maybe all of this can be avoided. But again, customization is always nice to have.Artem Kobzar
07/08/2026, 10:01 AMEdoardo Luppi
07/08/2026, 10:03 AMIt doesn't mean we're going to drop the annotationYou got me worried for a second here ahahaha The entire premise of the annotation is granular control, but I see that using a build DSL is better when you want export patterns/wildcards. Hopefully the two will coexist. But yes, I see the problem.
andylamax
07/08/2026, 11:39 AMtoString() export can also be ommited. Typescript tends to assume every object has a toString method, so no need to add it in the definitionsEdoardo Luppi
07/08/2026, 11:40 AMtoString.