Is there a way to use @JsExport annotations (or ot...
# multiplatform
g
Is there a way to use @JsExport annotations (or other annotations, specific to its own platform) in common code?
👀 1
j
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
You can declare an annotation with
expect
and declare
actual typealias
in platform code.
But I had problems using Java annotations with parameters this way.
r
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
@OptionalExpectation
For
@JsExport
in particular, it’s coming in 1.4-M2 and tracked here https://youtrack.jetbrains.com/issue/KT-35966
👍 1
r
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
.
That's great - I can use spring data annotations in common code now.