How I can describe static methods for JS classes?
# javascript
t
How I can describe static methods for JS classes?
b
turansky: companion objects allowed on external classes and members of companion object interpreted as static members
Copy code
external class A {
    companion object {
        fun foo()
        val bar: Int
    }
}

fun test() {
    A.foo()
    A.bar
}
Will be translated to:
Copy code
//...
function test() {
    A.foo();
    A.bar;
  }
//...
t
What about interfaces?
companions for external interfaces not allowed till Kotlin 1.1.2?! Right?
b
Yes, it’s prohibited since 1.1.2 because we think that external interfaces are not existed at runtime so it’s slightly strange to have any nested declaration inside.
Honestly, I don’t remember what compiler was generated for such cases before
If You have use cases for that feel free to share them here or in https://youtrack.jetbrains.com/issue/KT-16012