https://kotlinlang.org logo
#javascript
Title
# javascript
s

shama

01/30/2023, 8:56 PM
Does Kotlin
1.8
no longer generate
.d.ts
files or is there a configuration I’m missing? When on Kotlin
1.7.21
they generate in
build/developmentLibrary/
but with
1.8
they are no longer there.
b

Big Chungus

01/30/2023, 9:01 PM
It should. Are you using BOTH compiler mode by any chance? I think that dropped a support for dts
s

shama

01/30/2023, 9:02 PM
I’m using
IR
. I’ll try setting up a new project to be sure it’s not something unique in our project.
Yep even with the Full-Stack Web Application wizard, Kotlin
1.7.21
generates a
.d.ts
and updating to
1.8
it no longer does.
b

Big Chungus

01/30/2023, 9:20 PM
Maybe there's a new flag now that you need to flip explicitly? I assume you already use binaries.library()
s

shama

01/30/2023, 9:21 PM
Yeah checking through the changelog now. I tried with both
binaries.library()
and
binaries.executable()
too
b

Big Chungus

01/30/2023, 9:21 PM
Are you running some specific task to get that or just a catch-all "build" task?
s

shama

01/30/2023, 9:21 PM
/gradlew jsBrowserDevelopmentLibraryDistribution
b

Big Chungus

01/30/2023, 9:21 PM
Could be a case of task responsibilities changing maybe? Can you try "gradlew clean build"?
s

shama

01/30/2023, 9:22 PM
I’ve done a clean between each attempt to be sure. It doesn’t generate a
.d.ts
file in the
js/packages/<Project>/kotlin/
anymore either.
b

Big Chungus

01/30/2023, 9:23 PM
I'm also always using useCommonJs() Might be worth seeing if that changes anything if you don't use it yet
s

shama

01/30/2023, 9:27 PM
Hmm nope doesn’t work with
useCommonJs()
either on my end. I appreciate the help btw!
Just for the repro, I used the Full-Stack Web Application wizard in Intellij then changed
binaries.executable()
to
binaries.library()
. Running
jsBrowserDevelopmentLibraryDistribution
with
1.7.21
creates
.d.ts
files. Changing it to
kotlin("multiplatform") version "1.8.0"
and commenting out the deprecated
cssSupport.enabled = true
option, it no longer generates
.d.ts
files.
b

Big Chungus

01/30/2023, 9:33 PM
Booting up my pc to try it out
🙏 1
Aha! Looks like dts are now only generated for productionLibraries (so my initial suggestion to run
./gradlew clean build
would've worked for you.
Also be sure to have at least one @JsExport in your code.
image.png
s

shama

01/30/2023, 10:07 PM
Ah ha, you are amazing! Thank you for figuring that out. I see the
.d.ts
files now using productionLibraries.
🎉 1
b

Big Chungus

01/30/2023, 10:10 PM
Pro tip, when stuff is suddently missing always run the most expensive/generic task you can think of to check if it was really missing or just moved someplace else
In this case that was
build
or
assemble
s

shama

01/30/2023, 10:11 PM
I appreciate the tip! I’ll keep that in mind next time something goes wrong.
c

CLOVIS

01/31/2023, 8:51 AM
@Big Chungus while you're sharing pro tips, do you know of a way to easily find out which task creates a specific file? My current strategy of "look at the tasks that get executed, then execute each of them in order until the file exists" takes ages 😕
b

Big Chungus

01/31/2023, 8:57 AM
That would be my first instinct as well. To be more efficient you might check gradle scan - I think it list out task inputs and outputs. Alternatively something like this might work
Copy code
tasks {
  all {
    doFirst {
      println("$(task.name) outputs: $(outputs.files)")
    }
}
c

CLOVIS

01/31/2023, 9:03 AM
Oh, I'll try that, thanks
b

Big Chungus

01/31/2023, 9:04 AM
Let us know if any of the options worked
w

willyrs

04/21/2023, 1:47 PM
I don’t know if I can necropost this, but I have the same problem with kotlin 1.8.20 and I can’t find any d.ts file, not with binaries.executable() and jsBrowserProductionWebpack and neither with binaries.library() and jsBrowserProductionLibraryDistribution
b

Big Chungus

04/21/2023, 1:48 PM
Dts files are only generated for binaries.library()
Also they are skipped if your code has no @JsExport members
Here's your checklist for dts gen: 1. Use IR backend 2. Use binaries.library() 3. Have at least one entity in your code annotated with @JsExport
w

willyrs

04/21/2023, 2:21 PM
thanks! I think they changed the rules again.. It works with kotlin 1.8.0 but not with 1.8.20.. I’m trying with 1.8.10 now
my results: kotlin 1.8.0 -> d.ts are generated kotlin 1.8.10 -> doesn’t build: error An unexpected error occurred: “https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.8.10.tgz: Request failed \“404 Not Found\“”. kotlin 1.8.20 -> it builds but d.ts are not generated
j

jeran

05/17/2023, 2:41 PM
@willyrs or anyone, have you figured this out? I’m on kotlin 1.8.20, nothing i’ve done has gotten d.ts files to generate. using:
Copy code
js(IR) {
    nodejs()
    binaries.library()
}
worked fine with any 1.7.x versions we used
a

Andrey Tabakov

05/17/2023, 2:48 PM
@jeran add
generateTypeScriptDefinitions()
Copy code
js(IR) {
    generateTypeScriptDefinitions()
    binaries.library()
}
2
j

jeran

05/17/2023, 2:53 PM
sadly, i am getting this
a

Andrey Tabakov

05/17/2023, 2:56 PM
are you already set kotlin version to 1.8.20? May be you returned it to 1.7.0?
j

jeran

05/17/2023, 3:01 PM
i wondering if it might’ve been introduced in 1.8.21
no, it looks like it should be there… gonna keep digging into it
in case anyone comes across this
generateTypeScriptDefinitions()
was definitely the answer to my issue. some local transient build issue was causing gradle not to find it, but it is present in 1.8.20
👍 1
180 Views