https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
javascript
  • s

    Shannon Lloyd

    05/26/2020, 6:30 AM
    I noticed that sealed classes don't get written out as abstract classes when generating .d.ts files using 1.4-M1. They just get written out as regular classes. I have to remove the sealed modifier and replace it with abstract in Kotlin to get it to generate an abstract class in Typescript. Anyone know if this is deliberate? It'll break all my when-expressions if I can't use sealed classes in my models 😞 I also noticed that my enums didn't survive the translation into .d.ts files. All I see is:
    /* ErrorDeclaration: Class my.fully.qualified.enum.class.Name with kind: ENUM_CLASS */
    I'm new to TS, but I thought it had enums.
    :youtrack: 2
    a
    s
    • 3
    • 3
  • s

    spand

    05/26/2020, 7:55 AM
    We are having some trouble getting the new kotlinjs plugin to pick up our .yarnrc file. Is it working for anyone else?
    a
    i
    m
    • 4
    • 15
  • c

    christophsturm

    05/26/2020, 9:18 AM
    is there an example project where backend code and javascript frontend use the same kotlin data classes?
    t
    r
    +2
    • 5
    • 22
  • n

    Nicholas Bilyk

    05/26/2020, 7:00 PM
    I was curious if this is intentional -- Kotlin JS has a different default for maven publishing than JVM or MPP. In JVM and MPP publications are created automatically if you apply the
    maven-publish
    plugin, however for JS only projects this isn't the case. It's easy enough to add -
    val kotlinSourcesJar by tasks.named("kotlinSourcesJar")    
        publishing {
            publications {
                create<MavenPublication>("default") {
                    from(components["kotlin"])
                    artifact(kotlinSourcesJar)
                }
            }
        }
    However, this isn't really documented and feels inconsistent. This is with 1.4-M1 EAP.
    👍 1
    g
    d
    • 3
    • 2
  • t

    Tristan

    05/27/2020, 10:15 PM
    Hello, Is there any plans to share any article about how JetBrains did use Kotlin for Space? I heard it is built with Kotlin. I am interested to know what are the techniques used for such a big product. I was looking at improving the performances using Workers. But currently, it's not easy to generate multiple files with Kotlin (I think it's on the roadmap https://youtrack.jetbrains.com/issue/KT-33826) Kotlinx Coroutines is not supporting workers as well. There is some work done by people using Angular (https://stackoverflow.com/questions/43276044/angular-cli-generated-app-with-web-workers) I supposed it has to be implemented by a framework and not the language?
    s
    c
    • 3
    • 4
  • m

    Mranders

    05/28/2020, 2:36 PM
    Hi We're having some issues on our build server when attempting to build a branch using the new js-plugin. During the build, some third party node-module tries to log using node. However, this results in a permission error.
    > Task :kotlinNpmInstall
    error /var/jenkins_home/Build_pluginupgrades/build/js/node_modules/jss: Command failed.
    Exit code: 126
    Command: node -e "console.log('\u001b[35m\u001b[1mLove JSS? You can now support us on open collective:\u001b[22m\u001b[39m\n > \u001b[34m<https://opencollective.com/jss/donate>\u001b[0m')"
    Arguments: 
    Directory: /var/jenkins_home/Build_pluginupgrades/build/js/node_modules/jss
    Output:
    /bin/sh: 1: node: Permission denied
    
    > Task :kotlinNpmInstall FAILED
    When using the plugin, where is node/yarn installed?
    i
    n
    • 3
    • 9
  • f

    fkrauthan

    05/28/2020, 4:59 PM
    Does anyone here know if we are already closer to easy code splitting within KotlinJS? I saw a Discuss Thread where a Jetbrains developer hinted last year March that they are working on it
    ⬆️ 1
    a
    • 2
    • 4
  • s

    spierce7

    05/29/2020, 7:09 PM
    Has anyone tried the generated typescript definitions yet? I’m going to try it soon with my JS team so was curious if anyone had any experience before I try this next week
    s
    g
    +2
    • 5
    • 20
  • g

    Grantas33

    05/29/2020, 11:10 PM
    message has been deleted
    • 1
    • 1
  • g

    gabin

    05/30/2020, 6:01 PM
    Hi . I’ve created a new project through intellij Idea (New Project -> Gradle -> Kotlin/JS for browser) and get an error from start. What does it mean and how can I solve it?
    f
    • 2
    • 1
  • f

    frank

    05/30/2020, 11:36 PM
    I'm developing Kotlin/JS Project and I have created new sourceSets but by default makes the type = Multiplataform. How can change KotlinPlatformType in gradle? Gradle code:
    val backend by creating{}
    val webapp  by creating{}
    i
    • 2
    • 10
  • d

    dazza5000

    06/02/2020, 1:15 AM
    does anyone have a simple kotlin/js project that is part of a kotlin mp project that has tests written for the js piece?
    i
    • 2
    • 1
  • t

    Tristan

    06/02/2020, 11:47 PM
    Hello, Is it possible to set a breakpoint from intellij when using
    browserDevelopmentRun
    ?
    i
    • 2
    • 2
  • n

    napperley

    06/03/2020, 4:58 AM
    Busy playing around with Fritz2 after watching the very impressive VKUG presentation (

    https://youtu.be/s_C3uhThzgk▾

    ). With a new Kotlin JS project I discovered that the continuous deployment feature breaks when adding a new Kotlin JS library/framework (eg
    implementation("io.fritz2:fritz2-core-js:0.4")
    ):
    Error: ENOENT: no such file or directory, open '/home/napperley/idea_projects/kotlinjs-test/build/js/packages/kotlinjs-test/kotlin/kotlinjs-test.js'
    A bit annoying since it means the web page has to be manually refreshed in a web browser (eg Brave) every time code changes are made. Wondering if the continuous deployment feature can't handle pure Kotlin JS libraries/frameworks which don't rely on NPM ( https://github.com/jwstegemann/fritz2 ) 😆 .
    i
    • 2
    • 2
  • n

    napperley

    06/03/2020, 5:01 AM
    Anyone know where I can find the elusive JS file that is generated. The JS file doesn't seem to exist anywhere in the project directory, yet when the file is referenced in index.html the JS file is mysteriously found when running the run Gradle task.
    i
    • 2
    • 1
  • m

    Mananpoddarm

    06/03/2020, 5:14 AM
    Hi, is it possible to use rxjava in kotlin multiplatform?
    g
    • 2
    • 3
  • f

    frank

    06/03/2020, 12:57 PM
    I'm testing Koa.js in my Project Kotlin/JS but i cant make equivalent in kotlin for
    async
    and
    await
    from middleware of koa. Koa router:
    const router = require('koa-router')()
    
    router.get('/', async (ctx, next) => {
      await ctx.render('index', {
        title: 'Hello Koa 2!'
      })
    })
    I tried with js() function and coroutines but cant make it work. Any hint or confirm if avaible in kotlin/JS?
    a
    e
    • 3
    • 21
  • s

    spierce7

    06/03/2020, 4:30 PM
    Does kotlinx.serialization support the new JS IR compiler? @Grantas33 is saying that the class names that the IR compiler generates (that have
    _
    prefixes), aren’t properly serialized by kotlinx.serialization. @sandwwraith ^^
    s
    • 2
    • 1
  • s

    spierce7

    06/03/2020, 9:49 PM
    So I created a js project to test out the typescript definitions generated using 1.4-M2. It sounds like from the blog post that
    produceExecutable()
    is required to get the
    .d.ts
    files to generate, but I can’t find how to call
    produceExecutable()
    from the multiplatform plugin. Am I missing it? How would I get this to work?
    d
    • 2
    • 2
  • t

    Tristan

    06/04/2020, 1:28 PM
    Hello, any progress in the discussion with this issue (lazy import) https://youtrack.jetbrains.com/issue/KT-20679
    s
    a
    • 3
    • 4
  • a

    ankushg

    06/04/2020, 3:48 PM
    With inline classes being supported in the new IR for JS, is there a possibility for inline enum classes to be prioritized? https://youtrack.jetbrains.com/issue/KT-23823 TS “enums” are usually typed as unions (
    type MyEnum = "a" | "b" | "c"
    ). Having
    inline enum class
    support (especially with generates TS definitions) would help greatly with calling Kotlin/JS code from Typescript. EDIT: it looks like there are a few other ways to represent Enums in TS: • enum (
    enum MyEnum2 { A = "a", B = "b", C = "c")
    ) • const enum (
    const enum MyEnum2 { A = "a", B = "b", C = "c")
    ) I want proper mapping between Kotlin/TS enums -- inline classes and/or union types are just one way I see to get that
    g
    s
    s
    • 4
    • 8
  • f

    frank

    06/04/2020, 7:45 PM
    I update to last version
    Kotlin 1.4-M2
    and cant call to ':compileKotlinJs' tasks directly, Gradle module have tasks but not found in build.gradle.
    //Fail Call :compileKotlinJs tasks
    tasks.compileKotlinJs{
            kotlinOptions.outputFile = "${projectDir}/routes/node/index2.js"
            kotlinOptions.metaInfo = false
            kotlinOptions.moduleKind = "commonjs"
    }
    
    //Work call to :compileKotlinJs
    tasks {
        "compileKotlinJs"(org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile::class) {
            kotlinOptions.outputFile = "${projectDir}/routes/node/index2.js"
            kotlinOptions.metaInfo = false
            kotlinOptions.moduleKind = "commonjs"
        }
    }
    Any idea because dont work
    tasks.compileKotlinJs
    If exists in Gradle module?
    t
    i
    • 3
    • 7
  • s

    spierce7

    06/05/2020, 3:25 AM
    I’ve been playing around with exporting typescript definitions for a JS library using 1.4-M2. I handed the generated typescript definition over to someone on my JS team, but he told me it wouldn’t work because the typescript definition doesn’t have any export statements in the typescript definition. This would be a fairly major bug in typescript definition generation, so it seems unlikely and that my team is missing something, but other typescript definitions I look at all export what’s usable. Can anyone confirm if this is a bug? @Svyatoslav Kuzmich [JB] ^^
    s
    • 2
    • 2
  • v

    Vladislav Khikhlov

    06/05/2020, 1:30 PM
    Is there somewhere an example of multi-module project with new gradle plugin? I'm trying to migrate from kotlin-frontend-plugin and can't get everything done.
    t
    i
    r
    • 4
    • 11
  • n

    napperley

    06/07/2020, 5:54 AM
    It appears as though the chart.js module isn't being installed via npm (
    npm("chart.js")
    ). How do I get chart.js installed as a library? Is there a separate Gradle task that needs to be executed?
    g
    • 2
    • 6
  • h

    Hanno

    06/07/2020, 7:23 AM
    Hey guys, using kotlin 1.3.70, i Had some trouble with hot reloading and after some search i found this https://discuss.kotlinlang.org/t/kotlin-js-incremental-compilation/11380 and it made everything work... Which is strange because i read the linked ticket to be done Long time ago. Does anyone else have problems with hot reloading?
    t
    • 2
    • 2
  • n

    napperley

    06/08/2020, 12:39 AM
    Does Kotlin JS have a website similar to Definitely Typed (aka Kotlinly Typed) where Kotlin definitions for JS libraries/frameworks are hosted?
    t
    g
    +2
    • 5
    • 16
  • f

    frank

    06/10/2020, 8:43 AM
    [solved] I upgraded my webapp Project to Kotlin 1.4-M2 and cant find
    create
    variable in
    stdlib-js
    lib.
    import kotlin.browser.document
    
    document.create.div(classes = "chatWindow") {}
    Any equivalent in 1.4-M2 ?
    • 1
    • 1
  • c

    christophsturm

    06/10/2020, 9:22 AM
    can i configure the run task to open chrome instead of safari on macOS?
    j
    • 2
    • 2
  • l

    Luis Mirabal

    06/10/2020, 1:40 PM
    Hi I'm starting with Kotlin/JS and React and have a problem writing tests, even when the code being tested have nothing to do with DOM, I get:
    Error: Target container is not a DOM element.
    I found a possible solution in SO: https://stackoverflow.com/questions/61839800/unit-testing-in-kotlin-js But it's not ideal. Any ideas how to fix this?
    u
    • 2
    • 3
Powered by Linen
Title
l

Luis Mirabal

06/10/2020, 1:40 PM
Hi I'm starting with Kotlin/JS and React and have a problem writing tests, even when the code being tested have nothing to do with DOM, I get:
Error: Target container is not a DOM element.
I found a possible solution in SO: https://stackoverflow.com/questions/61839800/unit-testing-in-kotlin-js But it's not ideal. Any ideas how to fix this?
u

[JB] Shagen

06/10/2020, 6:08 PM
the problem is that the content is not loaded up to the point when tests are triggered?
l

Luis Mirabal

06/10/2020, 7:22 PM
Not sure to be honest, first time I try to use js
But I get the exact same problem as in the stack overflow post and their fix does work, it just feels a bit hacky
View count: 2