Hi all, another KMP -> JS question if anyone kn...
# javascript
a
Hi all, another KMP -> JS question if anyone knows: When compiling a Kotlin method with default values, it seems the current behaviour ( 1.7.10 ) is to make ALL parameters in the function signature ‘optional’ in terms of the Typescript definition, even the ones where we haven’t specified a default value. Is this by design? It seems unsafe, because the params without defaults will possibly be undefined when the function is called from JS. example code: Kotlin
Copy code
fun hello(param1:String, param2:String, param3:Boolean = false ) {}
JS.dt.ts
Copy code
hello(param1?: string, param2?: string, param3?: boolean): void;
b
Smells like a bug for youtrack
Which is expected seeing as d.ts generation is still experimental
a
I have noticed this as well, is there a ticket I can follow??
s
In
1.6.20
, default value support was broken for Typescript, so looks like they tried to fix it in
1.7.x
but now if you’ve one param with default value then all becomes optional. if you remove the default value from boolean above, then it works fine on
1.7.10
. So yeah definitely a bug at this point!