If we try to implement interface, it produce gener...
# javascript
u
If we try to implement interface, it produce generating
getter/setters
via
Object.defineProperty
. For example:
Copy code
external interface IModel {
    val id: Int
    var name: String
}

class CModel (
    override val id: Int,
    override var name: String
) : IModel
will transpilled to:
Copy code
function CModel(id, name) {
    this.id_4s8xc9$_0 = id;
    this.name_j0rqo7$_0 = name;
  }
  Object.defineProperty(CModel.prototype, 'id', {
    get: function () {
      return this.id_4s8xc9$_0;
    }
  });
  Object.defineProperty(CModel.prototype, 'name', {
    get: function () {
      return this.name_j0rqo7$_0;
    },
    set: function (name) {
      this.name_j0rqo7$_0 = name;
    }
  });
How to avoid generating
getter/setter
? I need to interact with JS/TS libs. And such libs see only mangled fields, because properties defined via
Object.defineProperty
not accessible by
Object.getOwnPropertyNames()
. Using
external interface
and
@JsName()
don't help. If we define
class
, which does not implement any
interface
such
getter/setters
will not be generated. I also noticed that such
getter/setters
are generated only for properties which have
override
g
not accessible by
Object.getOwnPropertyNames()
They are, if marked as enumerable See this issue https://youtrack.jetbrains.com/issue/KT-19016
Could you please add your use case to this issue
1