I'm trying out Kotlin Multiplatform for the first time, i've used the IntelliJ New Module to create a JVM/JS project
What is the correct way to add a new npm dependency that does have TypeScript support
should i just add it in the jsMain in build.gradle
which then generates kotlin files for this npm package ?
j
Joffrey
06/04/2020, 6:22 AM
If you just add the npm dependency, you won't be able to use it from Kotlin. In addition to declaring it in Gradle, you need Kotlin external declarations for it to work.
These declarations can be manually generated using Dukat via CLI as you pointed out, which then requires you to put the output files as sources in your project.
If these declarations don't need manual intervention, you can automate the process by making Gradle use Dukat for you. For this, you simply need to enable the Gradle property