https://kotlinlang.org logo
Docs
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
  • m

    McEna

    05/29/2019, 8:24 PM
    Folks? is anybody consuming kotlin/native made libraries from javascript/typescript projects? I've been reading, but I really could use a few pointers.
    n
    b
    14 replies · 3 participants
  • t

    thana

    05/31/2019, 1:17 PM
    can somebody point me to a kotlin-based application that makes use of a ServiceWorker?
    r
    2 replies · 2 participants
  • s

    spierce7

    05/31/2019, 5:20 PM
    Is there any news about being able to generate typescript bindings for kotlin-js code?
    s
    1 reply · 2 participants
  • t

    thana

    05/31/2019, 8:44 PM
    Note that Kotlin compiler does not apply such mangling to external declarations, so you don't have to use @JsName on them. Another case worth noticing is inheriting non-external classes from external classes. In this case any overridden functions won't be mangled as well.
    But it still will apply name mangling on properties, won't it?
    g
    2 replies · 2 participants
  • t

    thana

    05/31/2019, 8:52 PM
    even worse: id i use a
    data class
    not inheriting from anything that names aren't mangeled at all. but if i implemement or extend from a class declared external the names get mangeled contradicting what the documentation says
    u
    1 reply · 2 participants
  • j

    Joffrey

    06/03/2019, 9:01 PM
    I'm trying to write an external declaration for the following typescript interface:
    export interface Headers {
      'content-length'?: string;
    }
    Dukat generates the following, which is valid Kotlin in general:
    external interface Headers {
        var `content-length`: String?
            get() = definedExternally
            set(value) = definedExternally
    }
    But now the compiler complains:
    Name contains illegal chars that can't appear in JavaScript identifier
    Does this mean that the kotlin compiler doesn't support outputting JS with string properties? I tried with
    @JsName
    , but it doesn't accept the dash either. Is there a way to work around this? EDIT: question posted on StackOverflow https://stackoverflow.com/questions/56434633/external-declaration-gives-name-contains-illegal-chars-that-cant-appear-in-jav
    u
    2 replies · 2 participants
  • r

    Robert Jaros

    06/04/2019, 9:16 PM
    Anyone has encountered a problem with
    kotlin-frontend-plugin
    failing with
    error notarget No matching version found for kotlinx-serialization-runtime-js@0.11.0
    ?
    4 replies · 1 participant
  • u

    U75957

    06/05/2019, 6:26 AM
    How create custom sourceSet with Gradle Kotlin DSL? Not MPP (just JS project). Just custom sourceSet, which can be compiled separately and on which other sourceSets may depend.
    r
    4 replies · 2 participants
  • u

    [JB] Shagen

    06/05/2019, 2:20 PM
    Hey everyone! We are excited to announce that we've released today dukat@0.0.7, it's our new declaration converter which among other things is replacing ts2kt completely. Starting from this release ts2kt is deprecated, all relevant open issues will be transferred to the new repo. We've did our best to eliminate all the critical issues before this release but just like with any sofware it's very important to have a feedback. Feel free to use it, to report what you like and what you miss and, if needed, create an issue here - https://github.com/Kotlin/dukat/issues.
    🎉 14
    :kotlin: 3
    👍 3
    s
    b
    +1
    15 replies · 4 participants
  • c

    cfnz

    06/06/2019, 5:15 AM
    Hi, should kotlin js, in particular the react wrappers work with hot module reloading, and in particular the React Hot Loader (https://github.com/gaearon/react-hot-loader). I have been trying, but get a page reload on each build... Googling it seems HMR is somewhat supported (as used in the Kotlin Frontend Plugin), but is using the React Hot Loader with kotlin code an exercise in futility?
    s
    3 replies · 2 participants
  • t

    thana

    06/07/2019, 9:41 AM
    When will the compiler put properties on the
    prototype
    of a js class and when will it simply be on
    this
    ? What does this decision depend on?
    s
    d
    12 replies · 3 participants
  • a

    Alexander Weickmann

    06/07/2019, 1:33 PM
    How to create a Date object and subtract days from it? In JS, the accepted solution is:
    var d = new Date();
     d.setDate(d.getDate()-5);
    But the Kotlin JS Date object does not expose setDate ...
    l
    i
    +2
    11 replies · 5 participants
  • u

    U75957

    06/07/2019, 2:53 PM
    I expect that compile-time constants don't transpile to variables, but just substituted in the corresponding places. But all this constants from example, are transpiled to js:
    const val TEST1 = "test1"
    
    object Test2 {
        const val TEST2 = "test2"
    }
    
    class Test {
        object Test3 {
            const val TEST3 = "test3"
        }
    }
    r
    s
    9 replies · 3 participants
  • u

    U75957

    06/09/2019, 4:36 PM
    I use tests with mocha and expect that async
    @beforeTest
    and async
    @afterTest
    will be properly chained. But in fact
    @beforeTest
    ,
    @afterTest
    and an actual test starts in parallel. How to achieve the expected result?
    class TestA : CoroutineScope by GlobalScope {
    
        @BeforeTest
        fun beforeTest() = promise {
            println("beforeTest START")
            delay(100)
            println("beforeTest END")
        }
    
        @AfterTest
        fun afterTest() = promise {
            println("afterTest START")
            delay(100)
            println("afterTest END")
        }
    
        @Test
        fun test1() = promise {
            println("test1 START")
            delay(100)
            assertTrue(true)
            println("test1 END")
        }
    
        @Test
        fun test2() = promise {
            println("test2 START")
            delay(100)
            assertTrue(true)
            println("test2 END")
        }
    }
    result:
    JS: beforeTest START
    JS: test1 START
    JS: afterTest START
    JS: beforeTest END
    JS: test1 END
    JS: afterTest END
    
    JS: beforeTest START
    JS: test2 START
    JS: afterTest START
    JS: beforeTest END
    JS: test2 END
    JS: afterTest END
    u
    u
    +3
    19 replies · 6 participants
  • t

    turansky

    06/13/2019, 11:03 AM
    Is second variant more secure?
    -.kt
    ❓ 6
    e
    i
    3 replies · 3 participants
  • h

    hallvard

    06/14/2019, 1:49 PM
    I cannot seem to find
    window.navigator.sendBeacon
    . In JS I usually just do
    navigator.sendBeacon
    . Does anyone in here have any knowledge to share?
    l
    n
    5 replies · 3 participants
  • h

    hallvard

    06/15/2019, 10:48 AM
    Next question: I have custom gradles task that move and copy some files so that I get one single output file from transpilation and can then easily pack it in and out of a webjar. Now, I'd like to use the DCE tool on the resulting file, but cannot see how I tell the DCE tool to find the target
    .js
    file to work on. Is there a complete list of settings and configurations for the DCE tool somewhere? I find the references and examples on kotlinlang.org to be scarce ...
    1 reply · 1 participant
  • v

    Valentyn

    06/15/2019, 1:53 PM
    Hello all. I am looking for hello world maven application with kotlin javascript. Please help.
    h
    2 replies · 2 participants
  • g

    galex

    06/18/2019, 7:51 AM
    How can I compile a Kotlin/JS library (multiplatform) to an npm module and deploy it to npmpackages?
    h
    2 replies · 2 participants
  • j

    Jan Stoltman

    06/18/2019, 1:16 PM
    Hey guys, how can one implement/call/create/whatever a kotlin interface from JS?
    s
    u
    8 replies · 3 participants
  • t

    Toddobryan

    06/18/2019, 4:31 PM
    I'm kinda surprised I couldn't find an answer to this question from Googling, but maybe I didn't know the right incantation. I'm writing a library I'd like to use backend and on clients, and I'd like its treatment of regular expressions to be the same so that I don't have to worry that a regex will match on one side but not the other. Is there a way to do that, possibly by depending on a JVM Javascript engine or something?
    c
    i
    14 replies · 3 participants
  • u

    U75957

    06/19/2019, 7:15 AM
    To work with some third-party lib, I need to set property of
    prototype
    like this
    SomeClass.prototype.prop = "value"
    . But when I do:
    object SomeClass : SomeLibClass() {
        override var prop = "value"
    }
    it produce such js code:
    Object.defineProperty(SomeClass.prototype, 'prop', {
        get: function () {
          return this.prop_x8fmwh$_0;
        },
        set: function (prop) {
          this.prop_x8fmwh$_0 = prop;
        }
      });
    And it does not work. Looks like it's not equal to
    SomeClass.prototype.prop = "value"
    . Why? And how to force kotlin/js produce just
    SomeClass.prototype.prop = "value"
    ?
    s
    a
    5 replies · 3 participants
  • t

    thana

    06/19/2019, 11:07 AM
    has there been a change in how kotlin handles arrays? because i'm using
    someList.toTypedArray()
    somewhere and in the debugger i can see it uses an
    Array
    -implementation instead of a js-native array...
    a
    6 replies · 2 participants
  • i

    Ilya Goncharov [JB]

    06/19/2019, 12:30 PM
    Is it possible to disable node and yarn download with 1.3.40 eap version?
    a
    s
    +2
    12 replies · 5 participants
  • v

    victor

    06/19/2019, 3:52 PM
    What is a proper way to include KotlinJS’s lib from VueJS project. I’ve setup KotlinJS compiler to output CommonJS module. Add kotlin with npm --save and do the import. But have the following error:
    Uncaught TypeError: Cannot read property 'org' of undefined
        at eval (SharedCode.js?ae59:2368)
        at Module.eval (SharedCode.js?ae59:2859)
        at eval (SharedCode.js:3319)
        at Module../src/SharedCode.js (app.js:13570)
        at __webpack_require__ (app.js:767)
        at fn (app.js:130)
        at eval (main.js:18)
        at Module../src/main.js (app.js:14770)
        at __webpack_require__ (app.js:767)
        at fn (app.js:130)
    Is there any example to put some KotlinJS code into VueJS project?
    a
    4 replies · 2 participants
  • s

    snrostov

    06/19/2019, 4:45 PM
    Experimental Gradle support for NPM, Yarn, and Webpack for Kotlin/JS released in 1.3.40. Also test runners for Kotlin/JS now implement all Gradle Test runner APIs and behave in a way similar to the Kotlin/JVM test runner. https://blog.jetbrains.com/kotlin/2019/06/kotlin-1-3-40-released/
    👍 9
    ❤️ 3
    🎉 9
    v
    j
    +4
    36 replies · 7 participants
  • v

    victor

    06/19/2019, 5:36 PM
    (https://kotlinlang.org/docs/tutorials/javascript/working-with-modules/working-with-modules.html#using-commonjs)
    a
    15 replies · 2 participants
  • v

    victor

    06/19/2019, 5:38 PM
    Is there a bug in CommonJS kotlin generator?
    a
    1 reply · 2 participants
  • j

    Joffrey

    06/19/2019, 9:52 PM
    How do we enable the experimental npm/webpack support on the new Kotlin/JS gradle plugin 1.3.40?
    s
    3 replies · 2 participants
  • g

    gaetan

    06/20/2019, 11:53 AM
    I just created a small multiplatform JS/JVM project. It’s a Todo application that shares view rendering and state code. On the client, it uses a basic Redux implementation. Don’t hesitate to comment. https://github.com/gzoritchak/todokotlin
    🔥 1
    s
    s
    17 replies · 3 participants
Powered by Linen
Title
g

gaetan

06/20/2019, 11:53 AM
I just created a small multiplatform JS/JVM project. It’s a Todo application that shares view rendering and state code. On the client, it uses a basic Redux implementation. Don’t hesitate to comment. https://github.com/gzoritchak/todokotlin
🔥 1
s

sdeleuze

06/20/2019, 12:32 PM
How do you make the frontend files available in the backend project ?
g

gaetan

06/20/2019, 12:34 PM
In this kind of multiplatform project, I use a share directory data (not a good name!). The server must be launched using this directory as the working directory.
I must document and improve that.
👍 2
s

sdeleuze

06/20/2019, 12:35 PM
Ok, maybe worth to explicit in the README since that part is not obvious and multiple solutions exist.
👍 1
I am working on that as well on my sample
s

snrostov

06/20/2019, 1:16 PM
Just curious: why you use old multplatform plugins
kotlin-platform-common
,
kotlin-platform-js
,
kotlin-platform-jvm
instead of new
kotlin-multiplatform
?
g

gaetan

06/20/2019, 1:20 PM
Well, every time I tried, I faced some bugs. The last one: https://youtrack.jetbrains.com/issue/KT-24463
s

sdeleuze

06/20/2019, 1:34 PM
@snrostov How can I change the port used for
./gradlew :frontend:run -t
?
s

snrostov

06/20/2019, 1:37 PM
@sdeleuze
kotlin {
    target {
        browser {
            runTask {
                devServer = devServer.copy(port = 8081)
            }
        }
   }
}
s

sdeleuze

06/20/2019, 1:38 PM
Ok thanks
s

snrostov

06/20/2019, 1:39 PM
Also you can configure proxy to backend:
kotlin {
    target {
        browser {
            runTask {
                devServer = devServer!!.copy(proxy = mapOf("/api" to "<http://localhost:8081>"))
            }
        }
Where
<http://localhost:8081>
- backend endpoint
👍 1
@gaetan Ah… Yes, it is annoying IDE issue. But, as described in comments, the actual issue is that project building using IDEA internal build system, not Gradle. Hope it will be fixed in 1.3.50 (cc @yan)
s

sdeleuze

06/20/2019, 1:41 PM
For the port, maybe worth a shortcut for easier usage and discoverability?
s

snrostov

06/20/2019, 1:42 PM
Yes, the DSL should be better designed. It is more like internal feature for now. https://youtrack.jetbrains.com/issue/KT-32016
👍 2
g

gaetan

06/22/2019, 12:39 AM
@sdeleuze @bashor @snrostov I updated the project. It’s amazing how Kotlin fits well for redux implementation. The project have now coroutines remote calls with error management. We are going to use this architecture for play.data2viz.io.
😒uspend: 3
👍🏻 3
I’m in the process of migrating to new mpp and kts but, as always, I find it sooooo painful. I would like to copy/paste some examples and not suffer, reading a lot of doc for every line. 😭
s

snrostov

11/10/2020, 3:42 PM
@Ilya Goncharov [JB] please help
View count: 4