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

    Talon

    07/10/2018, 5:14 PM
    Trying to deserialize a polymorphic type.
    "Any type is not supported"
    s
    • 2
    • 3
  • e

    ehubbard

    07/11/2018, 2:49 PM
    Got a newb question for folks. The JS websocket definitions require an ArrayBuffer --- but I have code that hands me a ByteArray — There should be a way to convert them.. under the hood are they the same thing?
    s
    • 2
    • 3
  • o

    owlish

    07/12/2018, 8:56 PM
    I mean, what I would like to do, is call JS code - which would be executed in node - and get results from it into the kotlin app (which will be running on JVM). Is that possible?
    g
    • 2
    • 2
  • j

    jw

    07/15/2018, 1:21 AM
    can i somehow run webpack in two different configurations in a single module with the frontend plugin? (filed: https://github.com/Kotlin/kotlin-frontend-plugin/issues/83)
    e
    • 2
    • 3
  • j

    jw

    07/16/2018, 8:09 PM
    is there an easy way to reconcile the fact that some APIs are available globally in the browser but require
    require
    in node? For example, I want to test code that uses
    URL
    .
    Nevermind I'm an idiot and used a reeeeally old version of node.
    r
    • 2
    • 2
  • n

    Nail Gilaziev

    07/17/2018, 8:09 AM
    hello! when kotlin-js-wrappers libs on https://dl.bintray.com/kotlin/kotlin-js-wrappers will be updated to 1.2.51? when using kotlinx-serialization kotlin 1.2.51 is recomended, but kotlin-js-wrappers for 1.2.51 doesn't exist. for example, last version kotlin-react-dom - 16.4.1-pre.34-kotlin-1.2.50 Updated Jul 06.
    l
    • 2
    • 1
  • m

    marcinmoskala

    07/17/2018, 12:19 PM
    Because when I use "plain" in compileKotlin2Js then nothing is accessible from JS. I need JS filed generated that can be used from JS without modules required.
    d
    • 2
    • 6
  • e

    Edouard Goossens

    07/20/2018, 4:18 PM
    Hi everyone! Did anyone manage to successfully get external type definitions for Firebase using ts2kt? I’m getting a partial output with several errors.
    r
    • 2
    • 6
  • m

    Matt

    07/20/2018, 5:07 PM
    Sadly I get the same error with
    @JsNonModule
    r
    • 2
    • 6
  • g

    gbaldeck

    07/20/2018, 6:22 PM
    Has anyone had any success getting Kotlin to work with React Native?
    e
    b
    • 3
    • 4
  • k

    krtko

    07/20/2018, 10:44 PM
    Am I crazy or is geolocation not mocked in Kotlin.js?
    r
    • 2
    • 4
  • k

    kasper.kondzielski

    07/23/2018, 9:12 PM
    But still I am having:
    main.bundle.js:1 Uncaught (in promise) ReferenceError: JSONFormatter is not defined
        at P (main.bundle.js:1)
        at b (main.bundle.js:1)
    r
    a
    • 3
    • 6
  • k

    krtko

    07/24/2018, 11:28 PM
    Hey all, do you use any web frameworks with Kotlin? I have been developing my own with the idea of having abstracted ViewControllers, Routing, etc in a multi-platform way. Basically Everything is cross-platform except for the views. Would anyone be interested in this? I didn't originally plan on open sourcing it since I figured it would be to custom tailored to my own requirements. Also I figured most ppl use either React or Angular, which I am not a fan of and my approach might be to much like an iOS/Android app for web developers.
    a
    • 2
    • 2
  • d

    dany

    07/25/2018, 8:55 AM
    I am exactly in the same situation, currently all business logic in kotlin and all views in VueJs; but it is a pain to recreate Kotlin object into typesciprt ones: I did not try this project yet though: https://github.com/ntrrgc/ts-generator
    j
    • 2
    • 3
  • f

    frellan

    07/25/2018, 9:08 AM
    @dany thats the same one I am looking at as well! If one could integrate it into the build process so the models are always up to date and when I makes changes in the backend the typescript vue code stops working would be fantastic
    k
    d
    • 3
    • 17
  • k

    krtko

    07/27/2018, 9:03 PM
    Yea I don't mind concating them, but it won't export the library file unless I use DCE.
    a
    • 2
    • 2
  • k

    krtko

    07/27/2018, 9:27 PM
    Oddly enough dceOptions.devMode doesn't seem to work anymore
    a
    • 2
    • 4
  • a

    ankushg

    08/01/2018, 2:55 AM
    Another potentially silly question. I've got a JS project that defines its "enums" as hardcoded string constants in a big array. I've also got a Kotlin multiplatform project where I redefine those string constants as real `enum class`es and have some methods/classes that take them as inputs and use them as properties. I'm trying to interact with the Kotlin/JS output from the older JS project. I'd like the older JS project to be able to treat the enums as regular string literals when calling those methods accessing them as properties of other classes. Is there a standard way to do this? Here's a gist with a barebones example of what I'm talking about and some more details (including what I've tried and what else I think I can do): https://gist.github.com/ankushg/069c743f7fe40e71afbe67632d98b7bc
    a
    • 2
    • 13
  • s

    Sergi Ortega

    08/01/2018, 8:48 AM
    Hello everyone. Im creating a library with wrappers for redux and react/redux, One of the problems I have is that when I build the library for distribution, all the comments are gone. Any ideas on how to tell the compiler to keep the comments? maybe in the .kjsm file? Thanks!
    a
    • 2
    • 1
  • n

    Norg

    08/01/2018, 5:32 PM
    Hi everyone. I found a weird compiler behavior. Here is the row:
    attrs.caption = state.toBeDeleted?.asDynamic()["name"].toString()
    I'm expecting that if
    state.toBeDeleted
    is
    null
    , the rest of row will not be invoked, and
    null
    will be the value of the whole expression. But this row is compiled into:
    $receiver.attrs.caption = ((tmp$ = this$Content.state.toBeDeleted) != null ? tmp$ : null)['name'].toString();
    And the result is
    Cannot read property 'name' of null
    . Am I misunderstanding something?
    a
    • 2
    • 5
  • j

    jw

    08/02/2018, 3:06 AM
    i have 4 modules with the frontend plugin and npm install is just killing me in terms of build time. 99% of the modules that each one are installing are the same. apparently node has a mechanism for concurrent locking during install, but there doesn't seem to be a way to pass
    -g
    for the install task. I would also just love to see project.buildDir changed to rootProject.buildDir (if the locking works). But global would be preferred for CI so that I could share the global installs across runs (similar to how Gradle stuff is in ~/.gradle)
    ➕ 4
    s
    a
    +4
    • 7
    • 10
  • g

    gbaldeck

    08/02/2018, 9:11 PM
    Is there somewhere I can go to see what's on the roadmap for Kotlin.JS?
    a
    d
    • 3
    • 7
  • a

    ankushg

    08/02/2018, 11:59 PM
    Is there a way to change the name of the JS module generated by Kotlin? For example, if I'd like to prefix it with a scope (https://docs.npmjs.com/misc/scope)?
    a
    • 2
    • 15
  • n

    napperley

    08/04/2018, 4:28 AM
    Is it possible to set the module name for a Kotlin JS lib (a Kotlin Platform module) via Gradle Kotlin DSL?
    g
    • 2
    • 4
  • f

    fair_enough

    08/08/2018, 12:42 PM
    Hi, do you have simpliest example? I want to do library. For instance with kotlin frontend plugin. And I want to include bundle in js or typesript project and use it there
    r
    • 2
    • 6
  • a

    apomelov

    08/08/2018, 3:17 PM
    Hi. I've read in several sources that kotlin2js compilation has ES6 modules in a roadmap. Does anybody know how far is it?
    g
    a
    • 3
    • 3
  • a

    apomelov

    08/09/2018, 6:01 AM
    I'm trying to link with an external JS library using ts2kt. Typescript definition has a class with constructor. Constructor has an argument of type
    Config
    . There is also
    declare type Config = { ... }
    . In kotlin code
    Config
    becomes an external interface with plenty of optional vars. How should I create an instance of this interface? Just like this?
    val cfg = object : Config {
        override var width: dynamic
            get() = 200
            set(value) {}
        override var height: dynamic
            get() = 300
            set(value) {}
        ...
    }
    It looks monstrous for me...
    r
    b
    a
    • 4
    • 15
  • f

    fair_enough

    08/09/2018, 10:26 AM
    So, maybe I am asking wrong way. I want to do node js library. Which was originaly kotlinjs. And it is bundled. This library should have some js file, package.json and index.d.ts. So I did example project.
    compileKotlin2Js {
        kotlinOptions.outputFile = "${projectDir}/build/web/output.js"
        kotlinOptions.moduleKind = "commonjs"
        kotlinOptions.sourceMap = true
    }
    which is like:
    (function (_, Kotlin) {
      'use strict';
      var println = Kotlin.kotlin.io.println_s8jyv4$;
      var Kind_OBJECT = Kotlin.Kind.OBJECT;
      var Kind_CLASS = Kotlin.Kind.CLASS;
      function Example() {
        Example$Companion_getInstance();
        println('Example constructor');
      }
      Example.prototype.exampleMethod = function () {
        println('Example method');
      };
      function Example$Companion() {
        Example$Companion_instance = this;
      }
      Example$Companion.prototype.exampleStaticMethod = function () {
        println('Example static method');
      };
      Example$Companion.$metadata$ = {
        kind: Kind_OBJECT,
        simpleName: 'Companion',
        interfaces: []
      };
      var Example$Companion_instance = null;
      function Example$Companion_getInstance() {
        if (Example$Companion_instance === null) {
          new Example$Companion();
        }
        return Example$Companion_instance;
      }
      Example.$metadata$ = {
        kind: Kind_CLASS,
        simpleName: 'Example',
        interfaces: []
      };
      Object.defineProperty(Example, 'Companion', {
        get: Example$Companion_getInstance
      });
      var package$net = <http://_.net|_.net> || (<http://_.net|_.net> = {});
      var package$aliceintokyo = package$net.aliceintokyo || (package$net.aliceintokyo = {});
      package$aliceintokyo.Example = Example;
      Kotlin.defineModule('output', _);
      return _;
    }(module.exports, require('kotlin')));
    
    //# sourceMappingURL=output.js.map
    So now I want it to use in node js project. When I created simple nodeje module, installed it and I called
    var simple = require("simple");
    console.log(simple)
    I got printed:
    [object Module]
    When I did same with example, I got no error, but:
    [object Object]
    What am I doing wrong? How to require compiled kotlinjs?
    • 1
    • 1
  • s

    spierce7

    08/09/2018, 1:20 PM
    Are there any benchmarks of Kotlin-js? I'm interested to see how kotlin/native performs against hand written js
    r
    • 2
    • 2
  • g

    gcx11

    08/10/2018, 8:37 PM
    Is there any example for unit testing with gradle and qunit? My tests doesn't work when using code from my main module
    Error: Error loading module 'output'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'output'
    Gradle file: https://github.com/gcx11/FiveInLine/blob/master/build.gradle
    r
    • 2
    • 2
Powered by Linen
Title
g

gcx11

08/10/2018, 8:37 PM
Is there any example for unit testing with gradle and qunit? My tests doesn't work when using code from my main module
Error: Error loading module 'output'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'output'
Gradle file: https://github.com/gcx11/FiveInLine/blob/master/build.gradle
r

Roman Artemev [JB]

08/11/2018, 1:02 AM
Hi, I think this might be helpful https://github.com/JetBrains/kotlin-examples/tree/master/gradle/js-tests/qunit
g

gcx11

08/12/2018, 9:44 AM
Thanks, it helped me to get it working
View count: 2