Hi! Is there any Gradle Kotlin 1.4-dev plugin rele...
# javascript
l
Hi! Is there any Gradle Kotlin 1.4-dev plugin release that outputs typescript declarations already?
🚫 1
i
You can try to use new IR backend that has this functionality. You should add two compiler flags
Copy code
-Xir-produce-js
-Xgenerate-dts
But it's unstable, so use it on your own risk
Copy code
tasks.getByName<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile>("compileKotlinJs") {
    kotlinOptions {
        freeCompilerArgs += listOf("-Xir-produce-js", "-Xgenerate-dts")
    }
}
❤️ 2
l
Well, it just generate this from the entire library 🤣
Copy code
declare namespace firebase_multiplatform_core {
    type Nullable<T> = T | null | undefined
}
I guess it's a start!
🙃 2
b
You have to mark explicitly things to export using
JsExport
annotation.
@Lamberto Basti We are looking forward to your feedback ;)
🤩 2
l
Ok so the class I'm testing is this one:
Copy code
/**
 * The entry point of Firebase SDKs. It holds common configuration
 * and state for Firebase APIs. Most applications don't need to
 * directly interact with FirebaseApp.
 */
@JsExport
actual class FirebaseApp(val delegate: App) {

    actual companion object {

        actual val default: FirebaseApp
            get() = app().toMpp()

        actual fun getInstance(appName: String) =
            app(appName).toMpp()

        actual fun initializeApp(firebaseOptions: FirebaseOptions) =
            firebase.initializeApp(firebaseOptions).toMpp()

        actual fun initializeApp(firebaseOptions: FirebaseOptions, name: String) =
            firebase.initializeApp(firebaseOptions, name).toMpp()

    }

    actual val name: String
        get() = delegate.name

    actual val options: FirebaseOptions
        get() = delegate.options as FirebaseOptions

}
It errors saying:
Copy code
properties without fields are not supported com.github.lamba92.firebasemultiplatform.core.FirebaseApp.Companion_instance
But it does not says which lines. I tried putting all properties as lazy fields, it does not work either.
b
сс @Svyatoslav Kuzmich [JB]
l
I also tried to annotate every field/function (including the companion as well). No luck, same error
Any news?
s
Hi @Lamberto Basti! Thanks for trying it out! d.ts generation is an early prototype and it currently doesn't work with companion objects due to a bug you just found. We'll have to do more testing and bugfixes and hopefully release a preview version soon 🤞 . To get a grasp of whats currently works you can see our testcases from https://github.com/JetBrains/kotlin/tree/9594e9b3b1bb599207a720e9cec773315349a02d/js/js.translator/testData/typescript-export
❤️ 2
Also, you don't need to annotate every field and function. You would want to apply JsExport to file or a top-level declaration and it would automatically propagate itself to all nested members.
l
I tried the new IR on [this](https://github.com/CesareIurlaro/Android-Application/tree/kotlin-1.4-dev-ir-test) project. The subproject that need to interact with Angular is
kodein-di
. Unfortunately the compiler errors badly. I believe none of the classpaths gets resolved 😭 Just clone it and run
./gradlew :kodein-di:jsJar
to reproduce the issue. It uses Kotlin version
1.4.0-dev-2107-107
. Any help would be reaaaaly appreciated here. The exam at which the project needs to be presented at is the 20th T.T
s
Hey, IR-based libraries are not compatible with current Kotlin/JS libraries. You seems to use a lot of libraries and we don't have them published yet. Please don't rely anything important on this compiler yet.
😭 1
🧚‍♀️ 1
🐟 1
🤣 1
l
Well, I tried! In the meantime I'll go for a full Kotlin/JS frontend. Thank you for the help and time :)