i noticed that data class copy() methods don't hav...
# javascript
p
i noticed that data class copy() methods don't have default parameters (pretty much making them useless), even though javascript seems to support it: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters is there a ticket for this i can follow?
j
Many ES6/ES2015 features are not used
😢 1
You can finally target ES6 and get some, but I suspect post-K2 we'll get more
p
closing the loop here after trying to target ES6, seems like default parameters aren't used yet
actually upon digging some more: Kotlin JS generates a function like this:
Copy code
// Kotlin
data class TestDataClass(val test: String)

// Generated JS
protoOf(TestDataClass).copy = function (test, $super) {
  test = test === VOID ? this.test : test;
  return this.i(test);
};
and
VOID
here is defined as
js("void 0")
which evaluates to
undefined
(https://github.com/JetBrains/kotlin/blob/master/libraries/stdlib/js/runtime/void.kt) so we can at least somewhat get the desired copy behavior by passing in
undefined
to the fields you want to keep the same.