To work with some third-party lib, I need to set p...
# javascript
u
To work with some third-party lib, I need to set property of
prototype
like this
SomeClass.prototype.prop = "value"
. But when I do:
Copy code
object SomeClass : SomeLibClass() {
    override var prop = "value"
}
it produce such js code:
Copy code
Object.defineProperty(SomeClass.prototype, 'prop', {
    get: function () {
      return this.prop_x8fmwh$_0;
    },
    set: function (prop) {
      this.prop_x8fmwh$_0 = prop;
    }
  });
And it does not work. Looks like it's not equal to
SomeClass.prototype.prop = "value"
. Why? And how to force kotlin/js produce just
SomeClass.prototype.prop = "value"
?
s
What happens if you put
prop
on a companion object
u
@spand
prototype
and
companion object
are completely different concepts. Of course it does not work.
a
`object`'s are instantiated lazily in Kotlin/JS, which is one of the reasons why we don't do
SomeClass.prototype = <initializer>
I am not aware of an easy way to achieve what you want.
Could you give some context, when do you need a value on prototype directly?