Hey there I am noticing different behaviors betwe...
# javascript
a
Hey there I am noticing different behaviors between file level
@JsExport
and class/object/interface level
@JsExport
. Upto now, I don't know if this is a bug or a feature. So, someone at jetbrains please let me know which is which Finding Approach A: The code below
Copy code
@file:JsExport // NOTICE THIS FILE LEVEL ANNOTATION

interface Container<out T> {
    val value: T
}

interface MutableContainer<T> : Container<T> {
    override var value: T
}

class MutableContainerImpl<T>(
    override var value: T
) : MutableContainer<T>
Produces the following stripped down compiled javascript
Copy code
function Container() {
  }
  function MutableContainer() {
  }
  function MutableContainerImpl(value) {
    this.value_1 = value;
  }
  MutableContainerImpl.prototype._set_value__1325260276_ap8xuk_k$ = function (_set____804775014) {
    this.value_1 = _set____804775014;
  };
  MutableContainerImpl.prototype._get_value__3683422336_a43j40_k$ = function () {
    return this.value_1;
  };
Approach B: While the code
Copy code
@JsExport
interface Container<out T> {
    val value: T
}

@JsExport
interface MutableContainer<T> : Container<T> {
    override var value: T
}

class MutableContainerImpl<T>(
    override var value: T
) : MutableContainer<T>
Produces the following javascript code
Copy code
function Container() {
  }
  function MutableContainer() {
  }
  function MutableContainerImpl(value) {
    this.value_1 = value;
  }
  MutableContainerImpl.prototype._set_value__1325260276_ap8xuk_k$ = function (_set____804775014) {
    this.value_1 = _set____804775014;
  };
  MutableContainerImpl.prototype._get_value__3683422336_a43j40_k$ = function () {
    return this.value_1;
  };
  Object.defineProperty(MutableContainerImpl.prototype, 'value', { // Nptice the value property being declare here dynamically
    configurable: true,
    get: function () {
      return this._get_value__3683422336_a43j40_k$();
    },
    set: function (value) {
      this._set_value__1325260276_ap8xuk_k$(value);
    }
  });
Should this be expected? I don't see it in the documentations