I’m trying to generate a typed definition file ( t...
# javascript
s
I’m trying to generate a typed definition file ( typescript ) for my multi platform KotlinJS code. I wasn’t successful with any of the 2 plugins I found. Any of you had any luck ? Do you generate .d.ts file for your Kotlin code and how? I know Kotlin 1.4 should fix this but it’s not released yet and we don’t have a specific date right now. Thanks!
👀 1
👍 1
s
You could try the EAP 1.4-M1 if that is an option for you. This does create the d.ts file
t
Do you use
multiplatform
plugin or
js
?
s
I’m using the multiplatform plugin
I’d have to check my dependencies and see if they have a preview that support 1.4 🤔 . ..
t
Only JS plugin can generate
*.d.ts
as I know
s
Is this the case also for Kotlin 1.4 ?
t
Yes
s
🤔 So I’d have to create a JS only module that has dependency for my multiplatform target and this would work
t
So I’d have to create a JS only module that has dependency for my multiplatform target and this would work
Not so simple 🙂
@JsExport
annotations analized only for current module now
s
Meh… that’s sad… at least from a multiplatform point of view
i
multiplatform
plugin supports
d.ts
generation
@JsExport
works with transitive module (not only current module) too, but only with
js
specific sources Annotation is not accessible in common code now cc @Svyatoslav Kuzmich [JB]
s
@Ilya Goncharov [JB] Thanks for the clarification! So that mean I’ll have to create a JS only module and depend on my multiplatform
i
You can try pre-release version of 1.4
1.4-M1
was released already Check it out with
Kotlin/JS
section https://blog.jetbrains.com/kotlin/2020/03/kotlin-1-4-m1-released/
s
In 1.4 M1 JsExport is accessible inside existing multiplatform project in JS sourcesets. Creating a separate JS-only project is not necessary.
s
Oh great!
Is there a way to test 1.4 M1 without updating the whole project and all it’s dependencies?
i
If you want to get generated
d.ts
you need new compiler, and it requires new library format So I am afraid that there are no such ways
s
That was my understanding, but I was just asking to be sure 🙂 Thanks!