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
  • u

    U75957

    07/21/2019, 8:48 AM
    /* generated by dukat */ external open class A {
        open fun foo()
        open fun foo(p: Int)
    }
    
    /* abstract or */ open class B : A() // <--- OK. No errors
    
    class C : B() // <--- Error: JavaScript name foo is generated for different inherited members: fun foo(): Unit and fun foo(p: Int): Unit
    What's wrong?
    u
    b
    • 3
    • 7
  • b

    Big Chungus

    07/21/2019, 11:03 AM
    is ts2kt dead and dukat is its replacement?
    :yes: 1
    s
    • 2
    • 1
  • a

    altavir

    07/21/2019, 11:27 AM
    I've stuck with js build... again. I am using three-js library. And it is published in a complicated way so it has a main artifact and some additional modules that are part of npm distribution, but not parts of the main artifact. For example there is an
    OrbitControls
    module which just resides in
    node_modules/three/examples/jsm/controls/OrbitControls.js
    . On frontend plugin I just used a direct path to this module like
    @file:JsModule("../../node_modules/three/examples/jsm/controls/OrbitControls.js")
    . Now I can't use it since
    node_modules
    is no longer in build directory on
    1.3.50
    . Are there any suggestions?
    s
    • 2
    • 6
  • c

    Casey Brooks

    07/22/2019, 7:50 PM
    does DCE work with the new 1.3.41 Webpack multiplatform setup?
    :yes: 1
    r
    • 2
    • 12
  • a

    altavir

    07/24/2019, 2:25 PM
    OK, here is the test:
    fun testRead() {
            window.fetch("<https://drive.google.com/open?id=1w5e7fILMN83JGgB8WANJUYm8OW2s0WVO>").then {
                println("Fetched!")
                val string = it.body as String
                val xml = GDML.format.parse(GDML.serializer(), string)
                println(xml.world)
            }.catch {
                println("Fetch failed")
                println(it.message)
            }
        }
    What should I change to make it work
    g
    • 2
    • 1
  • l

    linux_china

    07/24/2019, 4:40 PM
    It’s possible to Adopt Svelte with Kotlin support?
    Svelte_with_Kotlin.kt
    r
    • 2
    • 1
  • l

    linux_china

    07/24/2019, 4:40 PM
    I just wonder Svelte with Kotlin, possible? I like to write script with Kotlin
    t
    • 2
    • 1
  • u

    utikeev

    07/25/2019, 8:41 AM
    I’m trying to adopt
    effector
    lib for Kotlin and stumbled upon the next problem. There are different config types in
    effector
    which are normalised before passing to factory. Normalisation uses
    Object.assign
    and leads to erasure of property getters, so the result object has generated property names, but no getters with initial names:
    nameOrConfig: createEffectConfig$ObjectLiteral
    handler_80ch0g$_0: ƒ fetchUser$lambda(payload)
    name_7uss69$_0: "Get user"
    handler: (...)
    name: (...)
    after normalisation becomes
    config:
    handler_80ch0g$_0: ƒ fetchUser$lambda(payload)
    name_7uss69$_0: "Get user"
    and
    handler
    and
    name
    properties are now unreachable for the library. The only way I found is using
    js { ... }
    wrapper and return dynamic object instead. Is there more Kotlin way to approach this problem?
    r
    • 2
    • 2
  • t

    thana

    07/25/2019, 1:36 PM
    why does
    Promise.reject()
    require a
    Throwable
    argument while in JS you can reject with any value?
    g
    i
    • 3
    • 4
  • j

    Joffrey

    07/25/2019, 3:00 PM
    I'm trying out the new 1.3.50-eap-5 Kotlin/JS gradle plugin. I get the following error:
    Could not determine the dependencies of task ':sw-ui-kt:packageJson'.
    > project ':sw-client' is not configured for JS usage
    Where
    sw-client
    is a Kotlin multiplatform subproject, and
    sw-ui-kt
    is a Kotlin/JS subproject depending on `sw-client`:
    kotlin {
        target {
            browser()
        }
        sourceSets {
            main {
                dependencies {
                    implementation(kotlin("stdlib-js"))
                    implementation(project(":sw-client"))
    //...
    Is it normal not to be able to depend on a multiplatform project from a JS one? Is there a way to declare the local dependency to the JS part of the multiplatform project?
    a
    • 2
    • 15
  • s

    Soren Valle

    07/25/2019, 7:07 PM
    I'm stuck. Applying "kotlin-dce-js" to a js project is kicking "error: duplicate target file will be created for..." on build. Google has yielded little answers. It seems as though it's trying to output two files with the same name from the node_modules to the same dir. I have failed to locate information on how or if I should configure the scope of what is processes beyond https://kotlinlang.org/docs/reference/javascript-dce.html#configuring. Any help would be appreciated. build.gradle.kts: https://gist.github.com/SorenV/6ae0de00c9529f04e05ef4f17df80d2b settings.gradle.kts: https://gist.github.com/SorenV/06753a7272481ee2ae4e0a8ddb8d853a
    a
    i
    a
    • 4
    • 13
  • t

    thana

    07/26/2019, 12:04 PM
    i use a javascript object as a "Map<String, Someobject>" to make integration easier for the frontend team. what type would you suggest i declare in kotlin here? currently its just
    dybamic
    which obviously makes handling hard in kotlin itself
    d
    • 2
    • 6
  • z

    Zachary Grafton

    07/26/2019, 9:17 PM
    @Soren Valle I use react quite abit, I might be able to help
    s
    • 2
    • 11
  • c

    czuckie

    07/27/2019, 9:13 AM
    morning all, has anyone had any luck writing an app using GJS? (The gnome javascript stuff, lets you write GTK+ apps in javascript and shell extensions.) I got something working in a very frankenstein way, was wondering if anyone had a nicer approach
    n
    • 2
    • 5
  • f

    fcosta

    07/29/2019, 1:38 PM
    Hi guys! I tried to upgrade my mpp project to Kotlin 1.3.41 and I started getting the following errors.
    $ ./gradlew :common:client:jsTest --console=plain
    
    > Configure project :common:client
    Kotlin Multiplatform Projects are an experimental feature.
    
    > Task :kotlinNodeJsSetup SKIPPED
    > Task :common:core:jsProcessResources NO-SOURCE
    > Task :kotlinNpmResolve FAILED
    > Task :common:client:nodeSetup
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':kotlinNpmResolve'.
    > Could not resolve all dependencies for configuration ':common:client:chatapp-client-npm'.
       > Could not find org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41.
         Searched in the following locations: <https://nodejs.org/dist/v1.3.41/kotlin-stdlib-common.jar>
         Required by:
             project :common:client
             project :common:client > project :common:core
       > Could not find org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.11.1.
         Searched in the following locations: <https://nodejs.org/dist/v0.11.1/kotlinx-serialization-runtime-common.jar>
         Required by:
             project :common:client
             project :common:client > project :common:core
       > Could not find org.jetbrains.kotlin:kotlin-stdlib-js:1.3.41.
         Searched in the following locations: <https://nodejs.org/dist/v1.3.41/kotlin-stdlib-js.jar>
         Required by:
             project :common:client
             project :common:client > project :common:core
       > Could not find org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:0.11.1.
         Searched in the following locations: <https://nodejs.org/dist/v0.11.1/kotlinx-serialization-runtime-js.jar>
         Required by:
             project :common:client
             project :common:client > project :common:core
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at <https://help.gradle.org>
    
    Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
    Use '--warning-mode all' to show the individual deprecation warnings.
    See <https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings>
    
    BUILD FAILED in 2s
    2 actionable tasks: 2 executed
    I was wondering why Gradle is trying to search for jars in
    nodejs
    ? Any hint?
    j
    • 2
    • 3
  • b

    Big Chungus

    07/29/2019, 6:56 PM
    Or maybe there are some dedicated builders already?
    z
    r
    • 3
    • 8
  • s

    Soren Valle

    07/29/2019, 9:03 PM
    Can't seem to get them to work.
    z
    • 2
    • 10
  • j

    Joffrey

    07/29/2019, 10:10 PM
    Has anyone managed to launch
    browserRun
    from the new Kotlin/JS gradle plugin? Where am I supposed to place my
    index.html
    and other static public files? I'm seeing a blank page with the text "Cannot GET /" at the top left-hand corner.
    s
    i
    s
    • 4
    • 21
  • v

    vsazel

    07/30/2019, 10:38 AM
    Hi. I'm using Kotlin 1.3.40 with JavaScript and want to call Node.js ftruncate. I have function like this
    fun createRandomFile(path: String, size: Long) {
        val fd = openSync(path, "a+")
        ftruncateSync(fd, size)
        closeSync(fd)
    }
    ftruncateSync is Node.js function defined in Kotlin as:
    external fun ftruncateSync(fd: Number, len: Number? = definedExternally /* null */): Unit = definedExternally
    I can pass Int to
    ftruncateSync
    with no problems, but top size is 1GiB for the file, because size of Int is limited. When I use Long, it ends with
    The "len" argument must be of type number. Received type object
    . So obviously there is no conversion for Long. Can this be done somehow?
    r
    s
    z
    • 4
    • 8
  • d

    diodredd

    07/30/2019, 11:58 AM
    Hi there, does anyone know is there some specific options for compileKotlin2Js to target node js, after compilation command line args actually ignored in output file.
    (function (_, Kotlin) {
      'use strict';
      var println = Kotlin.kotlin.io.println_s8jyv4$;
      function main(args) {
        println('Hello Javascript, from' + args[2]);
      }
      _.main_kand9s$ = main;
      main([]);
      Kotlin.defineModule('output', _);
      return _;
    }(module.exports, require('kotlin')));
    s
    • 2
    • 3
  • f

    fcosta

    07/30/2019, 1:22 PM
    Hey guys! I have a project with two mpp modules:
    core
    and
    client
    . I'm migrating them to
    1.3.41
    . When I try to run
    jsTest
    task on
    client
    module, the following error appears. Curious that, after some retries, the tests pass... 🤔 Maybe some lazy sync between modules? Have anyone already had this problem?
    Untitled
    c
    s
    • 3
    • 6
  • g

    gaetan

    07/31/2019, 4:00 PM
    @thana something like
    js("typeof window !== undefined") as Boolean
    t
    r
    s
    • 4
    • 9
  • f

    fcosta

    08/02/2019, 7:44 PM
    Is it possible to declare a
    devDependency
    in the new Kotlin JS plugin?
    s
    s
    • 3
    • 3
  • j

    Joffrey

    08/02/2019, 9:21 PM
    Does anyone know how to enable automatic Dukat run on npm dependencies with 1.3.50? This YouTrack issue has been marked as "fixed in 1.3.50", so it must be available, right?
    s
    • 2
    • 4
  • b

    Big Chungus

    08/03/2019, 12:28 PM
    Also did anyone managed to setup a project with it yet? The missing documentation is a big pain in the arse
    j
    s
    • 3
    • 3
  • j

    Juanoterocas

    08/03/2019, 5:22 PM
    Hi,I'm using react wrapper, how I can assign a RProps variable to RState var same type?, I'm trying to user init(props:RProps) override fun but it seems not being called.
    c
    • 2
    • 1
  • c

    Carson Graham

    08/05/2019, 9:14 PM
    Im trying to put together a kotlin multiplatform project, and the javascript compiler isn't making a out/ directory or putting anything in said directory which is a bit of a problem because those are the files I'm supposed to include in the html Heres my build.gradle https://pastie.io/ujwjtw.kotlin
    s
    s
    • 3
    • 3
  • j

    Juanoterocas

    08/07/2019, 5:05 PM
    Can I use Json from kotlinx serialization without reified methods?, I want to user with generics but only can be used in inline fun class StatusResponseHandler< T: Any>(var statusResponse: StatusResponse):Handler<T> { //private val clazz: KClass<T> init { } override fun success(): Boolean { return statusResponse.statusCode==200 } override fun failed(): ThrowableResponse { return ThrowableResponse(statusResponse.statusCode, statusResponse.description ) } @ImplicitReflectionSerializer override fun< T:Any> result(): T { // console.log("${statusResponse.data.toString()}") val json = Json(JsonConfiguration.Default) return json.fromJson( T::class.serializer(), statusResponse.data!!) } /*inline fun<reified T:Any> jsonResult():T{ return Json.nonstrict.parse( T::class.serializer(), statusResponse.data.toString()) }*/ }
    r
    • 2
    • 3
  • s

    Soren Valle

    08/09/2019, 11:13 AM
    Is there a way to initialize JsClass<T>?
    d
    • 2
    • 14
  • s

    Soren Valle

    08/10/2019, 5:21 PM
    Is there an effective way to include a local npm dependency in a gradle build?
    a
    d
    s
    • 4
    • 19
Powered by Linen
Title
s

Soren Valle

08/10/2019, 5:21 PM
Is there an effective way to include a local npm dependency in a gradle build?
a

anton.bannykh

08/13/2019, 2:04 PM
cc @snrostov
d

Dominaezzz

08/22/2019, 12:57 AM
👀
s

snrostov

08/23/2019, 9:07 AM
What does you mean by
local
npm dependency?
you can create gradle subproject, and add dependencies between subprojects. Kotlin Gradle JS plugin will link them together using
yarn
workspaces.
d

Dominaezzz

08/23/2019, 9:09 AM
I have a
library-version.tgz
file that I need to include as dependency.
Also, while we're on this topic, I also need to be able to specify plain http urls. Like
yarn add
supports. When I do
npm("http://....../package.tgz", "")
,
@
gets appended to the end of the resolved dependency, causing resolution to fail.
s

snrostov

08/23/2019, 9:17 AM
This looks like a bug, let me check…
@Dominaezzz This works for me:
implementation npm("@fancyapps/fancybox", "<https://github.com/fancyapps/fancybox#3.0>")
So, in your case it should be something like this:
npm("package", "http://....../package.tgz")
Does it work for you?
d

Dominaezzz

08/23/2019, 10:31 AM
Let me try.
Okay, that works. The dependency shows in the gradle window with
implementation(npm("@olm/olm","<https://packages.matrix.org/npm/olm/olm-3.1.0.tgz>"))
.
Although, I can't seem to get this to work.
js("""
global.Olm = require('olm')
""")
I get
Error: Cannot find module 'olm'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at test (/home/dominaezzz/IdeaProjects/MatrixKt/olm/src/jsMain/kotlin/sample/SampleJs.kt:13:22)
    at SampleTestsJS.testHello (/home/dominaezzz/IdeaProjects/MatrixKt/olm/src/jsTest/kotlin/sample/SampleTestsJS.kt:11:9)
    at /home/dominaezzz/IdeaProjects/MatrixKt/build/js/packages/MatrixKt-olm-test/kotlin/MatrixKt-olm-test.js:60:38
    at Object.fn [as test] (/home/dominaezzz/IdeaProjects/MatrixKt/build/js/packages_imported/kotlin-test-nodejs-runner/src/KotlinTestRunner.ts:12:25)
    at Object.test (/home/dominaezzz/IdeaProjects/MatrixKt/build/js/packages_imported/kotlin-test-nodejs-runner/src/KotlinTestTeamCityReporter.ts:80:28)
    at test (/home/dominaezzz/IdeaProjects/MatrixKt/build/js/packages_imported/kotlin-test/1.3.41/src/main/kotlin/kotlin/test/TestApi.kt:57:15)
I'm not sure if it's because of the dependency resolution or not. 🤷🏼
s

snrostov

08/23/2019, 12:14 PM
I guess you should write
require('@olm/olm')
instead of
require('olm')
d

Dominaezzz

08/23/2019, 12:17 PM
Oh, that did the trick. 😅 I'm new to npm and JS.
s

Soren Valle

08/23/2019, 12:21 PM
@snrostov Just seeing the response to this. I appreciate you getting back. What I meant by
local
was a js lib that I had written. I was trying to figure out how to include it as an npm dependency. So it would be properly resolved through
@JsModule
Without looking, npm allows for
file
resolution in
package.json
from what I remember.
npm()
didn't seem to allow for that.
Btw, thank for very much for all the work on this.
☝️🏼 1
View count: 5