Ademir Queiroga
10/21/2022, 5:12 PM@JsExport
@Serializable
data class Account(
val id: String,
val appName: String?,
val availableCredits: Float,
)
When exported to javascript and logging an instance of this class the property names get all messed up.
Account { n4n_1: 'test_id', o4n_1: 'test_name', p4n_1: 10 }
Does anyone know why and how to fix this? In the .ts
file the constructor has the all parameters correctly named and the IDE parameter hints are also all correct (and typed). I’m only facing this issue when logging the instances…Ademir Queiroga
10/21/2022, 5:15 PM@JsExport
Michael Friend
10/21/2022, 5:26 PMObject.defineProperty
call that lets you access the internal, mangled name property via the normal nameMichael Friend
10/21/2022, 5:31 PMfunction Account(id,appName,availableCredits) {
this.n4n_1 = id;
this.04n_1 = appName
this.p4n_1 = availbableCredits
}
then functions like this that declare the unmangled properties
Object.defineProperty(Account.prototype, 'id') {
...
get: Actual.prototype._get_n4n_1...
}
Ademir Queiroga
10/21/2022, 5:32 PMAdemir Queiroga
10/21/2022, 5:34 PMString
it prints the correct property names because it will probably use the data class generated toString()
Michael Friend
10/21/2022, 5:35 PMtoString()
directly i thinkAdemir Queiroga
10/21/2022, 5:36 PMAdemir Queiroga
10/21/2022, 5:36 PMMichael Friend
10/21/2022, 5:39 PMts
file to be helpful to get a general overview of whats exported but looking at the generated JS code was necessary if you wanted to figure out what was actually going onAdemir Queiroga
10/21/2022, 5:43 PMAdemir Queiroga
10/21/2022, 5:44 PMpackage-lock.json
? I’m using ktor
and specifically for the JS module I had to manually install some missing dependencies required by itMichael Friend
10/21/2022, 7:27 PMJared Vu
11/09/2022, 7:13 PMAdemir Queiroga
11/09/2022, 7:18 PM