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

    frank

    01/19/2021, 7:22 PM
    [Solved] How can instance an object of type dynamic without
    js()
    function? Code:
    external fun require(module: String): dynamic
    fun App() { 
      val Koa        = require("koa")
      val app        = Koa() //Dont work: Generate Koa() in JS script need new Koa() 
      val app        = js("new Koa()") // GOOD
    }
    Generate this:
    var Koa = require('koa');
    var app = Koa(); //BAD: i need new Koa() in JS script
    t
    • 2
    • 11
  • m

    Matthieu Stombellini

    01/20/2021, 2:32 PM
    Hey everyone, I wanted to use MSAL in Kotlin/JS with Dukat but I'm getting a "External type extends non-external type" on this class:
    external open class ClientAuthError(errorCode: String, errorMessage: String = definedExternally) : AuthError {
    AuthError itself is:
    typealias AuthError = Error
    Error is Kotlin's stdlib Error What can I do to fix that?
    t
    • 2
    • 2
  • a

    Animesh Sahu

    01/20/2021, 6:20 PM
    Are enums accesible from js (are they exported?)?
    a
    a
    • 3
    • 2
  • a

    Animesh Sahu

    01/20/2021, 6:22 PM
    Anybody have idea how to publish the end result of compilation to npm?
    👍 1
    v
    • 2
    • 3
  • a

    Animesh Sahu

    01/21/2021, 8:41 AM
    How are function types mapped to js? is
    () -> Unit
    compatible to be exported?
    s
    • 2
    • 1
  • a

    Animesh Sahu

    01/21/2021, 8:41 AM
    Can we have a decompiler for Kotlin -> JS, just like Kotlin -> Java? 👀
    s
    • 2
    • 1
  • a

    Animesh Sahu

    01/21/2021, 9:59 AM
    interestingly
    Promise<Unit>
    is unexportable 👀 should use
    Promise<dynamic>
    ? is there something like java.lang.Void or something for js?
    s
    • 2
    • 2
  • a

    Animesh Sahu

    01/21/2021, 10:57 AM
    Its just
    @Test
    annotation of
    kotlin.test
    package
    s
    • 2
    • 7
  • a

    Animesh Sahu

    01/21/2021, 11:37 AM
    Did I declared the module wrong?
    t
    • 2
    • 11
  • f

    frank

    01/21/2021, 12:48 PM
    If I install kotlin together with kotlinx-coroutines-core via NPM There are dependency conflicts, but if I remove kotlin package in my package.json resolve conflicts and finds the kotlin and coroutines modules. Does kotlinx-coroutines-core include the Kotlin package in NPM?
    "dependencies": {
     "kotlin": "^1.4.0",  // Conflict with kotlinx-coroutines-core package
     "kotlinx-coroutines-core": "^1.4.2",
    },
    npm ERR! code ERESOLVE
    npm ERR! ERESOLVE unable to resolve dependency tree
    npm ERR!
    npm ERR! While resolving: node-server@0.1.0
    npm ERR! Found: kotlin@1.4.21
    npm ERR! node_modules/kotlin
    npm ERR!   kotlin@"^1.4.0" from the root project
    npm ERR!
    npm ERR! Could not resolve dependency:
    npm ERR! peer kotlin@"1.4.0" from kotlinx-coroutines-core@1.4.2
    npm ERR! node_modules/kotlinx-coroutines-core
    npm ERR!   kotlinx-coroutines-core@"^1.4.2" from the root project
    a
    • 2
    • 2
  • m

    Martin Nowosad

    01/21/2021, 4:17 PM
    has anyone tried kotlin with vue?
    👀 2
    a
    l
    +3
    • 6
    • 15
  • p

    Pavel Janečka

    01/23/2021, 10:13 AM
    Hello everyone, anyone having problem with js build location with kotlin multiplatform project? I have KMP that has following `build.gradle.kts`in
    commonMain
    for the
    js
    target
    js(LEGACY) {
        browser {
            binaries.executable()
            webpackTask {
                cssSupport.enabled = true
            }
        }
    }
    and if I run the `jsBrowserDevelopmentRun`task (in project root) the started webpack-dev-server serves from
    <project-root>/mainModule/build/processedResources/js/main/
    path, but the actual build is located at
    <project-root>/build/js/packages/<project-name>-mainModule/kotlin-dce-dev/<project-name>-mainModule.js
    how can I get to the build fil in my
    index.html
    then (located in
    <project-root>/mainModule/src/jsMain/resources/index.html
    )? Even if I hardcode relative path to the build file, the dev server won't serve it (I guess it's forbidden to go up from serve path - for security reasons - by default).
    t
    c
    • 3
    • 7
  • d

    dave08

    01/24/2021, 1:16 PM
    Hi! It's my first time trying to compile a Kotlin Js library (3rd party), and the build keeps on getting stuck at kotlinNpmInstall... I tried googling and saw that some set the npm registry or empty the cache, tried that, but still getting stuck... did anyone encounter this before?
    p
    j
    • 3
    • 74
  • l

    Lammert Westerhoff

    01/24/2021, 8:57 PM
    I can’t seem to find any examples doing multipart form upload (for uploading images). has anyone accomplished doing javascript multipart upload using ktor?
    t
    • 2
    • 7
  • m

    Matthieu Stombellini

    01/24/2021, 9:08 PM
    Hello, I'm trying to use Microsoft Graph types (https://www.npmjs.com/package/@microsoft/microsoft-graph-types) with generateExternals = true. The problem is that microsoft graph types has a List type of its own that "shadows" kotlin.collections.List as what's generated seems to be in the "root package". Isn't there a way to put the types generated for that library in a separate package automatically?
    🇳🇴 1
    t
    • 2
    • 4
  • a

    Animesh Sahu

    01/25/2021, 9:08 AM
    How to define external declaration of a static function?
    • 1
    • 1
  • e

    Erdem

    01/25/2021, 7:40 PM
    Hello. I am writing a multiplatform library which will be used by desktop and web applications also. I want to use Kotlin JS with electron or something similar and I want to access Filesystem apis via Node js exclusively for desktop version. So right now I am trying to find a way to achive this. I am thinking of 2 ways but dont know what to do technically. First one is to use directly electron and its nodeIntegration feature but I couldn't use node apis via Kotlin. (Tried to run in electron window but getting 'fs' not found error and I don't have an idea how to configure Webpack) Second one is to render the application in a local server and show it in electron but I dont know is it technically possible with Kotlin or not What you guys recommend me to do?
    r
    • 2
    • 7
  • k

    Kabbura

    01/26/2021, 8:30 AM
    Hi everyone I am writing a Kotlin/JS library and want to enable the IR compiler backed. In gradle it would be
    kotlin{ js(BOTH) }}
    , however I am using Maven. Does anyone know how to do this in Maven and pom.xml?
    t
    • 2
    • 3
  • j

    Jilles van Gurp

    01/27/2021, 1:57 PM
    Is there some trick to get sourcemaps working with kotlin js and the multiplatform plugin? I set sourceMaps to true in the browser runTask, source map files get generated but I see no sign of the browser doing anything with them. Also the .map files seem unavailable via the dev server (I get a 404 when I request them). What am I missing? I'm using the fritz2 framework.
    s
    n
    +2
    • 5
    • 13
  • f

    ftomassetti

    01/28/2021, 11:14 AM
    Newbie to the JS and multiplatform system here. I would like to ask you how usable is the new JS backend introduced in v1.4. My case is this: we have a multiplatform library that we would like to use on the JVM and inside web applications written in TypeScript. It is not clear to me if it is better to use the old JS backend or the new one, and it is difficult for me to assess how much trouble I will get in using the Kotlin library from TS code. Could you share your experience, please?
    👀 1
    r
    • 2
    • 5
  • w

    Wishnuprathikantam

    01/28/2021, 3:52 PM
    Hey Kotlin JS Community! I am new to Kotlin/JS and I would like to ask can I develop an SPA entirely in Kotlin/JS (preferably kotlin-react) ? (Note: I have very little knowledge in react) Also any impact on performance? Suggest me any resources to get started with kotlin/js Thanks in advance.
    a
    j
    • 3
    • 2
  • a

    Alexander Weickmann

    01/29/2021, 9:51 AM
    Somebody seen this exception before during IntelliJ build? (Build using gradlew is successful)
    Kotlin: [Internal Error] java.io.IOException: Failed to open zip file: .../build/js/node_modules/react/index.js
    	at org.jetbrains.kotlin.utils.JsLibraryUtils.traverseArchive(JsLibraryUtils.kt:138)
    	at org.jetbrains.kotlin.utils.JsLibraryUtils.copyJsFilesFromZip(JsLibraryUtils.kt:122)
    	at org.jetbrains.kotlin.utils.JsLibraryUtils.copyJsFilesFromLibraries(JsLibraryUtils.kt:50)
    	at org.jetbrains.kotlin.jps.targets.KotlinJsModuleBuildTarget.copyJsLibraryFilesIfNeeded(KotlinJsModuleBuildTarget.kt:127)
    	at org.jetbrains.kotlin.jps.targets.KotlinJsModuleBuildTarget.doAfterBuild(KotlinJsModuleBuildTarget.kt:121)
    	at org.jetbrains.kotlin.jps.build.KotlinBuilder.doBuild(KotlinBuilder.kt:456)
    	at org.jetbrains.kotlin.jps.build.KotlinBuilder.build(KotlinBuilder.kt:304)
    	at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1441)
    	at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1100)
    	at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1224)
    	at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:1066)
    	at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:832)
    	at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:419)
    	at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:183)
    	at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:132)
    	at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:302)
    	at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:132)
    	at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:219)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    Caused by: java.util.zip.ZipException: error in opening zip file
    	at java.util.zip.ZipFile.open(Native Method)
    	at java.util.zip.ZipFile.<init>(ZipFile.java:225)
    	at java.util.zip.ZipFile.<init>(ZipFile.java:155)
    	at java.util.zip.ZipFile.<init>(ZipFile.java:126)
    	at org.jetbrains.kotlin.utils.JsLibraryUtils.traverseArchive(JsLibraryUtils.kt:136)
    	... 20 more
    m
    • 2
    • 2
  • a

    Animesh Sahu

    01/30/2021, 12:14 PM
    Ok seems it was picked after clean build into the jar, but this doesn't seem to work
    public external fun require(module: String): dynamic
    val something = require("./<some non constant value>")
    It says
    Error: Cannot find module './<...>'
    t
    • 2
    • 2
  • a

    Animesh Sahu

    01/30/2021, 12:37 PM
    Hmm, seems like tests run on
    <root_dir>/build/js
    where the resources are not copied, is it intended behavior??
    t
    • 2
    • 12
  • j

    Jan

    02/02/2021, 7:55 PM
    Hey, I wanted to get into KotlinJS today but I can not seem to get it working. I tried every template in the setup dialogue for a new project and even download the code from try.kotlin. I'm a relatively new programmer so I don't really know what information to include here. Anyways: Gradle seems to have this problem: "execution failed for task ' kotlin npm install'" And even while it's running I get this message warning workspace-aggregator-4b3bae44-befc-4a3d-a00e-f37f3ece851c > confexplorer-test > mocha > debug@3.2.6: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797) warning workspace-aggregator-4b3bae44-befc-4a3d-a00e-f37f3ece851c > confexplorer > webpack-dev-server > chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies. warning workspace-aggregator-4b3bae44-befc-4a3d-a00e-f37f3ece851c > confexplorer-test > mocha > mkdirp@0.5.3: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.) warning workspace-aggregator-4b3bae44-befc-4a3d-a00e-f37f3ece851c > confexplorer > webpack-dev-server > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2. warning workspace-aggregator-4b3bae44-befc-4a3d-a00e-f37f3ece851c > confexplorer-test > mocha > chokidar > fsevents@2.1.3: "Please update to latest v2.3 or v2.2" warning workspace-aggregator-4b3bae44-befc-4a3d-a00e-f37f3ece851c > confexplorer > webpack > watchpack > watchpack-chokidar2 > chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies. warning workspace-aggregator-4b3bae44-befc-4a3d-a00e-f37f3ece851c > confexplorer > webpack-dev-server > chokidar > braces > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated warning workspace-aggregator-4b3bae44-befc-4a3d-a00e-f37f3ece851c > confexplorer > webpack-dev-server > chokidar > braces > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated My node version is 14+ (I downloaded the LTS version) and installed yarn (1) Any suggestions on how to get it running? I tried googling it but had no success. Thanks in advance
    t
    • 2
    • 6
  • a

    Animesh Sahu

    02/03/2021, 4:03 AM
    Do singletons have JS interop, how do you access the instance :blob-thinking-upside-down:?
    t
    • 2
    • 3
  • a

    Animesh Sahu

    02/03/2021, 10:42 AM
    Is there a way to rename the exported module, or make them top level?
    t
    • 2
    • 12
  • a

    Animesh Sahu

    02/03/2021, 10:51 AM
    Is there a way to stop mangling names for a class/interface?
    s
    t
    • 3
    • 10
  • s

    Sanat, Web developer

    02/03/2021, 2:28 PM
    How can I get free Javascript logo stickers?
    f
    h
    • 3
    • 6
  • a

    Animesh Sahu

    02/04/2021, 9:50 AM
    Is this a bug? Why's the function declared twice?
    • 1
    • 4
Powered by Linen
Title
a

Animesh Sahu

02/04/2021, 9:50 AM
Is this a bug? Why's the function declared twice?
it results in infinite recursion 🤔
return this.addShortcut(keySet, triggerOnPressed, handler);
                ^

RangeError: Maximum call stack size exceeded
    at JsKeyboard_0.addShortcut (d:\Projects\KotlinProjects\keyboard-mouse-kt\keyboard-kt\build\publications\npm\js\keyboard-kt.js:15003:17)
    at JsKeyboard_0.addShortcut (d:\Projects\KotlinProjects\keyboard-mouse-kt\keyboard-kt\build\publications\npm\js\keyboard-kt.js:15003:17)
    at JsKeyboard_0.addShortcut (d:\Projects\KotlinProjects\keyboard-mouse-kt\keyboard-kt\build\publications\npm\js\keyboard-kt.js:15003:17)
    ...
It is defined as:
@JsName("addShortcut")
public fun addShortcut(
    keySet: String,
    triggerOnPressed: Boolean = true,
    handler: () -> Unit
): () -> Unit {
    return delegate.addShortcut(parseKeySet(keySet), triggerOnPressed.toKeyState()) { handler() }
}
🤔
Oh Ok, my fault, the js doesn't support default parameter before the non-default param
Though code shouldn't compile 😛
View count: 9