Is there a way to use @JsExport annotations (or other annotations, specific to its own platform) in common code?
👀 1
j
Justin
05/24/2020, 5:47 PM
If you figure this out (I’m told it is possible using version 1.4-M2 of Kotlin and the js plugin), I’d love to see what your build.gradle.kts looks like. I’m hoping to use that patterns to auto generate typescript defs for my nodeJs library target.
👍 1
r
Robert Jaros
05/24/2020, 5:51 PM
You can declare an annotation with
expect
and declare
actual typealias
in platform code.
Robert Jaros
05/24/2020, 5:52 PM
But I had problems using Java annotations with parameters this way.
r
russhwolf
05/24/2020, 5:55 PM
If the annotation has parameters then you need `expect`/`actual` for them as well. It’s doable, but it’s a bit of a pain because you can’t make use of
I've just tested the `expect`/`actual` for annotations with parameters and something had to be fixed in Kotlin in the last six months, because it works fine for me now. Even with
@OptionalExpectation
.
Robert Jaros
05/24/2020, 6:39 PM
That's great - I can use spring data annotations in common code now.