[kotlin - Why can't I use @JsExport in commonMain?...
# javascript
n
[kotlin - Why can't I use @JsExport in commonMain? Workaround with expect/actual seems to work fine - Stack Overflow](https://stackoverflow.com/questions/79782181/why-cant-i-use-jsexport-in-commonmain-workaround-with-expect-actual-seems-to)
t
It works for me in
commonMain
Additional import
import kotlin.js.JsExport
required
n
interesting maybe i am missing some dependency in commonMain. its not getting resolved for me
t
Missed
js
target?
n
I do have JS target, I have tested that I am able to use it on the browser.
Copy code
js {
        browser {
            binaries.executable()
        }

        // Enable TypeScript definition generation for all JS-enabled libraries
        generateTypeScriptDefinitions()
    }
t
Is it IDEA problem or you receive compile error too?
Copy code
js {
    browser()
    binaries.executable()

    // Enable TypeScript definition generation for all JS-enabled libraries
    generateTypeScriptDefinitions()
}
n
Compile as well
Copy code
> Task :asgardCoreShared:compileCommonMainKotlinMetadata FAILED
e: file:///usr/local/workplace/thorg-root/source/libraries/kotlin-mp/asgardCoreShared/src/commonMain/kotlin/asgardCoreShared/fs/file/FileShared.kt:5:15 Unresolved reference 'js'.
t
Which Kotlin version do you use?
n
Looks like I am a bit behind: Kotlin version: 1.9.23
Are you on 2+?
(going to see if I can upgrade to see if the issue goes away)
t
Yes, I use latest release version
e
I'd recommend upgrading for the simple fact K1 is deprecated at this point.
👍 1
n
After upgrading to 2.1,
@JSExport
works in commonMain, thank you Victor & Edoardo
😜 1