https://kotlinlang.org logo
Join Slack
Powered by
# javascript
  • m

    MrPowerGamerBR

    09/11/2025, 7:23 PM
    Is it possible to use
    @JsName
    on properties declared on a
    @JsPlainObject
    ? I wanted to change some
    snake_case
    variables into
    camelCase
    , to make it look "better" in Kotlin I tried searching for it, but the only result of someone trying to do this was this conversation: https://kotlinlang.slack.com/archives/C0B8L3U69/p1728428182216839 However after testing it, it doesn't seem to work on Kotlin 2.2.0 😞
    t
    • 2
    • 9
  • m

    Marc

    09/12/2025, 11:41 AM
    Are unsigned types fully supported on JS? I was trying to use them but I ran into a strange error:
    Copy code
    fun main() {
        ubyteArrayOf(
            *listOf(ubyteArrayOf())[0]
        )
    }
    results in:
    Copy code
    Unhandled JavaScript exception: listOf(...).get_c1px32_k$(...).slice is not a function
    https://pl.kotl.in/nEyBqjkBZ The same code works just fine when replacing
    ubyteArrayOf
    with
    byteArrayOf
    or running it on JVM instead.
    👀 2
    e
    • 2
    • 11
  • c

    CLOVIS

    09/13/2025, 4:01 PM
    Worried about bundle size? Here are two options that can help decrease it: • Using ESM modules • Using ES2015 language features Both of these articles give examples of how the options affect the generated code.
    ❤️ 11
    kodee loving 4
    🆒 1
  • e

    edenman

    09/16/2025, 8:43 PM
    Anybody else ran into this issue before? IDE isn’t able to resolve KotlinJsTargetDsl and it makes dev very annoying bc all the JsExport stuff shows red in the editor https://youtrack.jetbrains.com/issue/KT-81089/
    a
    • 2
    • 1
  • a

    Andreas Martin Mørch

    09/19/2025, 12:22 PM
    Anyone else run into an issue where changing the version of an npm dependency (via the Gradle DSL, i.e.
    implementation(npm(package, version))
    does not invalidate build cache? Kotlin 2.2.0, Gradle 8.12 Running build before and after changing the NPM dependency shows the same build cache key for
    compileKotlinJs
    . I would expect this to trigger a failed build and prompt the user to run
    kotlinUpgradeYarnLock
    like normal.
    a
    e
    a
    • 4
    • 4
  • s

    Stefan Oltmann

    09/21/2025, 3:03 AM
    While waiting for AWS SDK Multiplatform I wonder why there a no Kotlin-wrappers available for the official AWS S3 JS lib… isn’t that thing popular?
    a
    t
    • 3
    • 2
  • b

    Bernhard

    09/25/2025, 7:59 AM
    I'm writing type defs and came across
    Copy code
    {GridCoordinates2D|HexagonalGridCube2D|Point} HexagonalGridCoordinates2D
    and wondered, if there was a way to model that in Kotlin. Couldn't you use a marker interface for that? As in: an empty interface that all of these types extend?
    ✅ 1
    e
    t
    • 3
    • 9
  • j

    Jan Biedermann

    09/26/2025, 6:14 AM
    Hello everybody, how can i instruct gradle to get a npm dependency directly from a github repo instead of npmjs.com?
    e
    • 2
    • 9
  • o

    Oliver.O

    09/26/2025, 12:33 PM
    How can I pass a parameter from the Gradle command line to my JS tests (Node, browser, Wasm)? Example: Indicate if tests run on CI.
    v
    e
    +2
    • 5
    • 17
  • l

    Luv Kumar

    09/26/2025, 4:56 PM
    Hi all, today I noticed that there are no null checks for non nullable fields for generated JS code in KMP. I was assuming that the behaviour might have been similar to JVM where generated bytecode has null checks and code fails fast but it is not. How do people overcome this usually ? I can manually add null checks in
    init {}
    block but not only kotlin gives warning for that, it's cumbersome process to add to all exposed classes and would pollute the code as well.
    e
    s
    c
    • 4
    • 7
  • h

    Horatio Thomas

    09/30/2025, 10:31 AM
    Just decided to open source this investment tracker I've been working on as a personal passion project: https://github.com/TENET-THEORY/knance. It is probably the only sample out there that shares code between ktor and next js. Inspired by https://github.com/Kotlin/kmp-fullstack-conference-cms. If you like it, give it a star!
    👀 1
    K 1
    a
    • 2
    • 3
  • n

    Nickolay

    10/03/2025, 10:21 PM
    [kotlin - Why can't I use @JsExport in commonMain? Workaround with expect/actual seems to work fine - Stack Overflow](https://stackoverflow.com/questions/79782181/why-cant-i-use-jsexport-in-commonmain-workaround-with-expect-actual-seems-to)
    t
    e
    • 3
    • 17
  • a

    Artem Kobzar

    10/07/2025, 7:00 AM
    Good morning everyone ☀️ I need your input so much in the following question. In the thread, please share how you publish Kotlin/JS artifacts (not KLIB, but the executable) to a registry (e.g., NPM, JSR, Maven) and any pain points you've encountered with the approach. Thank you for the help 🙏 Artem, Kotlin/JS Lead
    👀 2
    a
    e
    +5
    • 8
    • 41
  • e

    Edoardo Luppi

    10/07/2025, 12:25 PM
    Kotlin 2.2.21-RC is out with a couple of fixes for K/JS. https://github.com/JetBrains/kotlin/releases/tag/v2.2.21-RC
    🎉 7
  • n

    Nickolay

    10/09/2025, 4:19 PM
    [kotlin - Can we expose interfaces from
    commonMain
    to JS that can be implemented in Typescript? - Stack Overflow](https://stackoverflow.com/questions/79786639/can-we-expose-interfaces-from-commonmain-to-js-that-can-be-implemented-in-type)
    t
    • 2
    • 3
  • m

    MrPowerGamerBR

    10/10/2025, 2:12 AM
    How can you create Web Components using Kotlin/JS? I did try to follow this guide and, while it did work in the past, it seems that the
    kotlin-browser
    bindings for Web Components have changed quite a bit, and now I'm not able to get a custom element to work
    a
    t
    a
    • 4
    • 24
  • a

    Alex Styl

    10/13/2025, 9:26 AM
    Major bottleneck for me right now with kotlin/js is the compilation speed. It slows down the dev loop dramatically vs just using javascript. This is while building backends on nodejs Everything else is fantastic
    e
    g
    a
    • 4
    • 20
  • e

    Edoardo Luppi

    10/13/2025, 9:41 AM
    Edit: https://kotlinlang.slack.com/archives/CDFP59223/p1759383119112699 What's up with this warning in 2.2.20? I suppose it's an IDE bug, and I don't have to worry about anything.
    a
    t
    s
    • 4
    • 6
  • n

    Nickolay

    10/13/2025, 9:25 PM
    Is there a way for generated typescript files
    d.ts
    to have KDoc comments transferred over to
    d.ts
    from the Kotlin files?
    b
    a
    • 3
    • 2
  • c

    Chanjung Kim

    10/20/2025, 9:21 AM
    I've noticed that the
    js(...)
    intrinsic only supports ES5 syntax. The version of GWT used by the Kotlin/JS compiler also predates the release of the ES6 standard. I couldn't find any official documentation describing the exact behavior of the intrinsic, but is enforcing ES5 kind of a spec of Kotlin/JS?
    a
    t
    • 3
    • 8
  • r

    Robert Jaros

    10/25/2025, 6:49 PM
    I'm testing Kotlin
    2.3.0-Beta1
    and trying to
    @JsExport
    a class with suspending method. I'm getting
    Declaration of such kind (suspend function) cannot be exported to JavaScript.
    error. I thought it had been fixed as https://youtrack.jetbrains.com/projects/KT/issues/KT-56281. Was I wrong?
    ✅ 1
    h
    a
    • 3
    • 4
  • m

    MrPowerGamerBR

    10/25/2025, 8:21 PM
    What are some tips and tricks to reduce the Kotlin/JS production bundle size? There is a lot of scattered tips across the web (and here too) but some of them aren't applicable anymore so I'm wondering what actually works on recent Kotlin versions kodee loving
    ☝️ 1
    t
    j
    c
    • 4
    • 19
  • s

    Seth Madison

    10/27/2025, 11:21 PM
    I think I’ve stumbled upon a fairly serious compiler bug in 2.2.21. https://youtrack.jetbrains.com/issue/KT-81971/Kotlin-JS-incorrectly-compiles-get-to-kotlin.js.get It seems that an inlined/reified function with Any as its type param (inside of a constructor) always gets compiled to
    kotlin.js.get
    . This is breaking our
    koin
    integration.
  • m

    MrPowerGamerBR

    10/28/2025, 2:47 AM
    It seems that using
    eval
    on a project still causes the project's bundle size to shoot up for some unknown reason I did talk about that bug 1+ year ago here on this channel, but that time I could fix the bug by creating proper typings, but sadly this time I really needed to use
    eval
    (executing scripts sent in HTML fragments by the server) https://kotlinlang.slack.com/archives/C0B8L3U69/p1715660256035359 So here's a workaround: Instead of using
    eval
    directly, use
    window.asDynamic().eval(element.innerHTML)
    Bundle sizes: • With
    eval(element.innerHTML)
    (from
    kotlin.js
    ): 1.788KB • With `window.asDynamic().eval(element.innerHTML)`: 1.030KB
  • s

    Sebastien Leclerc Lavallee

    10/28/2025, 5:01 AM
    Hello! 👋🏻 Let say I have a KotlinJS module in my project, named
    moduleA
    . I want to have another module that would be able to showcase how to use that
    moduleA
    . I have this right now:
    Copy code
    plugins {
        kotlin("multiplatform")
    }
    
    kotlin {
      js {
        browser()
      }
    
      sourceSets.jsMain.dependencies {
        implementation(project(":moduleA"))
      }
    }
    Inside my sample app, I have that
    index.html
    where it auto import
    <script type="application/javascript" src="sampleApp.js"></script>
    that is server by webpack. How can I access that
    moduleA
    from a
    <script>
    tag inside the index.html ? Thanks!
    a
    e
    • 3
    • 22
  • s

    Sam

    10/29/2025, 9:28 AM
    Hey folks, has anyone manage to access static resources from the
    jsTest
    resources directory? No matter what I do I seem to just get a 404 It's a service worker so it needs to be accessible as a static file off the root path I've tried the following (with absolute path) but still getting a 404
    Copy code
    val devServer = (webpackConfig.devServer ?: KotlinWebpackConfig.DevServer())
                        webpackConfig.devServer = devServer.copy(
                            static = (devServer.static ?: mutableListOf()).apply {
                                add("<ABSOLUTE PATH>/>/src/jsTest/resources/")
                            }
                        )
    t
    • 2
    • 18
  • n

    Nathan Bedell

    10/30/2025, 2:08 PM
    Hey all, does anyone have more context on this error? Couldn't find anything by googling: "Dependency to project with multiple js/wasm compilations is not supported yet" The error is clear enough. I have a module in my project that declares two js targets (with a gradle attribute to distinguish them), and another module with those two same js projects that I want to depend on the other module. I know this is a bit of an unusual use-case, but basically we have two separate products that are both JS, but we need different actual implementations for both (and both are browser targets as well). Any potential work-arounds, and any clue when this will be supported in the future?
    t
    e
    • 3
    • 16
  • h

    Horatio Thomas

    11/02/2025, 9:11 AM
    Anyone know if there is a gradle plugin to use with something like this: https://github.com/adamko-dev/kotlinx-serialization-typescript-generator. Was thinking about using it to generate my response models from my ktor backend and possible functions to wrap the rest api
    t
    a
    • 3
    • 2
  • e

    Edoardo Luppi

    11/03/2025, 6:41 PM
    @Artem Kobzar regarding the
    export default
    of plain objects, I've seen that exporting something like
    Copy code
    val obj = js("{}")
    Generates something on the line of
    Copy code
    var obj = {};
    var x = { get: obj };
    export default x;
    I don't understand the
    get:
    part to be honest. I understand
    getInstance
    for instances of Kotlin classes/objects, since they can be lazy, but not for JS objects or externals.
    a
    • 2
    • 4
  • t

    turansky

    11/04/2025, 1:10 PM
    In latest KFC plugins
    16.0.0
    we use Rolldown by default. It creates production build 3 times faster in our Kotlin/JS cases (2 min -> 40 sec) 😜 2% bundle reducing - additional bonus. Both JS and WasmJS targets supported. Special thanks to @Michael Porotkin
    👍 5
    👀 1
    e
    a
    • 3
    • 6