Brian Hoffmann
07/14/2024, 11:44 AM.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:
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?audax
07/16/2024, 10:56 AMjs(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-directoryBrian Hoffmann
07/16/2024, 11:21 AMuseCommonJs()
… 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.
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 😄audax
07/16/2024, 11:22 AM