Follow up question regarding JsExports. Asking to...
# javascript
a
Follow up question regarding JsExports. Asking to see if someone already asked so that I may not open a duplicate ticket currently exporting
Copy code
val lambdaFunction: (user: User)->Unit
yields the following typescript definitions
Copy code
readonly lambdaFunction: (p0: User)-> void
Which hurts readability. I would expect it to be exported to
Copy code
readonly lambdaFunction: (user: User)-> void
Is there already a ticket for this?
b
Hmm, maybe try adding @JsName("user") on that argument?
a
fails with:
Unsupported [annotation on parameter in function type]
b
Ah, was a wildcard anyways...
Can you not just use regular fun instead?
a
I wish I could, javascript doesn't play well with an exported unbounded functions which calls member variables using the
this
keyword.
ends up throwing
undefined
all over the place
b
Hmm, bind it to class via asDynamic() in init block?
a
As expected, kotlin syntax wont allow
Copy code
init {
  doSomething.asDynamic().bind(this) // error
}

fun doSomething(user: User) {

}
Fails with: Function Invocation expected
b
Ah, you need fun reference, so ::doSomething
Just guessing