is there guide how to write kotlin bindings for np...
# javascript
s
is there guide how to write kotlin bindings for npm projects manually. dukat is giving me errors.
v
That's "normal". Dukat will hopefully improved further after the new IR backend is stabilized. Imho the best way currently is to use Dukat and then fix the errors it produced. Some do that manually and check in the files, I prefer to generate the files and post-process them to fix the errors.
t
Which library from npm do you need?
s
We use Dukat to generate externals and then remove code we don't need and then fix errors in remaining code. That worked out well so far.
n
@Big Chungus how do you handle types that can be varying types eg
Boolean | Number | String
? I am trying to write bindings for Motion-Framer (unsuccessfully, this is the most difficult library I've seen in terms of typing), and the majority of its values can be multiple types. This forces me into dynamic. Also, kinda a bummer that dynamic and jsObject cannot work together so that a dynamic value can have a jsObject with any values.
b
Your only option for now is either pick one of them or use dynamic type.
However for member function arguments this could be partially improved by function overloads external class Test { fun test(arg: String) fun test(arg: Number) fun test(arg: Boolean) }
Any
type would work as well
Finally, dynamic does not need jsObject, because you can use dot notation to refer to any props directly
Copy code
external val window: dynamic

fun main() {
  println(window.location)
}