How do you type a mixin api like this one: ```clas...
# javascript
b
How do you type a mixin api like this one:
Copy code
class Base {
    sayHo() {
        console.log("ho")
    }
}

function Mixin(base) {
    return class New extends base {
        sayHi() {
            console.log("hi")
        }
    }
}

class Child extends Mixin(Base) {

}

const x = new Child()
x.sayHi()
x.sayHo()
1
e
I'd say you'd end up with just 2 external classes. Effectively
Child
is extending
Base
.
Copy code
external class Base {
  fun sayHo()
}

external class Child : Base {
  fun sayHi()
}
I don't think the function has to be considered here.
b
right, I need to call that Mixin function from a library though
e
Mmm I think I need some kind of practical example of how you'd like to use it in Kotlin
b
oh, I'm fine with extending a class
e
I just don't understand why you'd want to call the
Mixin
function from Kotlin, that's it
b
I need to generate js like this
Copy code
class MyApplication extends HandlebarsApplicationMixin(DocumentSheetV2) {
their API is class based
and they are rediscovering the bad patterns of the late 2000s
e
I'm not sure it's possible. But I never interop-ed with that kind of stuff, happy to be proven wrong!
This generates the code you mentioned
Copy code
@JsName("HandlebarsApplicationMixin(DocumentSheetV2)")
@Suppress("NAME_CONTAINS_ILLEGAL_CHARS")
public open external class HandlebarsApplicationMixin
However, without a compiler plugin, the inputted type can't be dynamic
I also need to open a YT issue to allow
NAME_CONTAINS_ILLEGAL_CHARS
suppressions in K2
b
thank you!
e
An issue I see is the lack of an import for
DocumentSheetV2
. If it doesn't exist in the global scope, the code will fail at runtime
b
yes it's on the global scope
✔️ 1
e