Automatic generation of external declarations with Dukat
Dukat is a tool currently in development which allows the automatic conversion of TypeScript declaration files () into Kotlin external declarations. This aims to makes it more comfortable to use libraries from the JavaScript ecosystem in a type-safe manner in Kotlin, reducing the need for manually writing external declarations and wrappers for JS libraries.
The npm
dependency function takes a third parameter after the package name and version: generateExternals
. This allows you to control whether Dukat should generate declarations for a specific dependency:
dependencies {
}
You can use the flag kotlin.js.generate.externals
in your gradle.properties
file to set the generator’s behavior for all npm dependencies simultaneously. As usual, individual explicit settings take precedence over this general flag.
Manually generating external declarations via Gradle task
It is recommended to only provide external declarations manually in your source folder or enabling the generation of external declarations at build time for any single dependency. Doing both can result in resolution issues.