how do you handle js objects? looks like you can u...
# javascript
b
how do you handle js objects? looks like you can use interfaces https://kotlinlang.org/docs/js-interop.html#external-interfaces but that looks painful; can you simply use data classes instead?
1
e
Nope. The only way to do it without
external interface
s is via
jso<Type> { }
, which is very inconvenient as it only allows
var
properties. @turansky is there a way to allow interfaces with
val
properties using
jso
? With externals you'll be able to use
@JsPlainObject
since K2.
b
oh, I see
it's not documented, it's in the release notes
t
K2 with
@JsPlainObject
can be used right now
e
I guess
jso
+
interface
and
val
would require some kind of error suppression via compiler plugin
t
jso
is for very complex/generic interfaces only and work with
val
- isn't case for
jso
For K2 single
jso
case - props of html elements
e
Mmmh last time I used
jso
I couldn't use
val
properties, I had to declare everything as
var
. Did I miss something?
t
@JsPlainObject
:)
e
Still very much unusable tho. Need proper IDE support
b
how do you handle default values for @JsPlainObject?
can't use definedExternally
e
No, you can't use default values yet.
b
so you need to pass in all values to a function in this case?
passing objects to js functions is kinda the solution to named parameters
t
so you need to pass in all values to a function in this case?
Only non-nullable
b
oh, thank you