Typescript Definitions not being generated since u...
# multiplatform
b
Typescript Definitions not being generated since upgrade from Kotlin 1.9.24 I've got a couple of multiplatform modules. One contains code that is integrated by a nodejs component. I used the generated Typescript definitions as part of the integration. But since I upgraded to Kotlin 2.0.0 the
.d.ts
file is missing. I played around with the gradle config of the module, but I can't find any combination that results in the TS types get generated. The configuration itself didn't change when upgrading Kotlin. Here is a snippet:
Copy code
js(IR) {
    moduleName = "common-foo"

    nodejs()
    useCommonJs()
    generateTypeScriptDefinitions()
    binaries.library()
}
The resulting JS library in
build/dist/js/productionLibrary
has a package.json that even references
"types": "common-foo.d.ts"
but the file is not there. The documentation states a combination of
binaries.executable()
and
browser()
-- but but even when I apply this, I don't get the TS definition. Did anybody had a similar experience? What am I missing?
a
This works for me:
Copy code
js(IR) {
        browser {
            @OptIn(ExperimentalDistributionDsl::class)
            distribution {
                outputDirectory.set(projectDir.resolve("output"))

            }
        }
        binaries.library()
        nodejs()
        generateTypeScriptDefinitions()
    }
and I get the typescript definitions and the module in the output-directory
b
That’s pretty much what I do, except I also apply
useCommonJs()
… But you made me rethink about my Gradle setup. I found my mistake. Thanks Jens! 🤗 For the sake of completeness, this is what I did: In the root
build.gradle
I apply compiler arguments for all modules.
Copy code
subprojects {
    afterEvaluate {
        // <https://github.com/JetBrains/compose-multiplatform/issues/2929>
        tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile>().configureEach {
            compilerOptions {
                freeCompilerArgs = listOf("-Xklib-enable-signature-clash-checks=false")
            }
        }
}
By assigning a new list, obviously I’ve overwritten anything set before. I changed it to
freeCompilerArgs.add(...)
Surprise: now it works 😄
a
Always a pleasure to be a rubber duck! 😄
rubber duck 1
🙌 1