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

    Artur Gniewowski

    01/18/2022, 11:04 AM
    How to add SVG in compose and change its color by CSS color or fill param?
    n
    n
    • 3
    • 2
  • g

    gaetan

    01/18/2022, 11:08 AM
    Does anyone know how to write in groovy the equivalent of
    rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin::class.java) {
        rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "..."
    }
    v
    • 2
    • 4
  • g

    goncalossilva

    01/18/2022, 5:28 PM
    Is there a place to report problems generating externals for npm dependencies for specific libraries? Kotlin/dukat might be it, but it doesn’t look very active.
    v
    • 2
    • 4
  • n

    Norbi

    01/19/2022, 5:34 PM
    I have a multiplatform project that compiles successfully. But when I try to run the Compose/Web subproject using
    jsBrowserDevelopmentRun
    , I get the following "internal compiler error", without any context about the cause of the problem. Do you have any idea how can I find the root of the problem? Besides,
    jsBrowserProductionRun
    seems to work OK (but it is too slow to be usable instead of
    jsBrowserDevelopmentRun
    ).
    java.lang.AssertionError: Assertion failed
    	at org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.JsAstUtilsKt.translateCallArguments(jsAstUtils.kt:343)
    	at org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.JsAstUtilsKt.translateCall(jsAstUtils.kt:111)
    	at org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrElementToJsStatementTransformer.visitCall(IrElementToJsStatementTransformer.kt:140)
    :youtrack: 1
    • 1
    • 2
  • j

    jeff

    01/21/2022, 3:40 PM
    Maybe this is a dumb question, but what's the easiest way to get the equivalent of Kotlin/JVM's
    readLine()
    in Kotlin/JS (nodejs target)?
    v
    • 2
    • 12
  • p

    Peter

    01/22/2022, 9:31 PM
    Hello, I'm trying to create this class in kotlin/js
    .left-slide {
      height: 100%;
      width: 35%;
      position: absolute;
      top: 0;
      left: 0;
      transition: transform .5s ease-in-out;
    }
    So far I have
    styledDiv {
                        css {
                            height = LinearDimension("100%")
                            width = LinearDimension("35%")
                            position = Position.absolute
                            top = LinearDimension("0")
                            left = LinearDimension("0")
                            transition = ???
    
                        }
    ...}
    and I don't know how to create this transition. Is someone able to help me ? Thank you in advance
    a
    • 2
    • 4
  • j

    jeff

    01/24/2022, 8:00 PM
    I'm using Kotlin/JS with IR compiler:
    kotlin {
         js(IR) { ... }
     }
    and when I try to add ksp:
    plugins {
         ...
         kotlin("js") version "1.6.10"
         id("com.google.devtools.ksp") version "1.6.10-1.0.2"
     }
    it gives me this error:
    You already registered Kotlin/JS target with another compiler: legacy
    Googling indicates that ksp does support IR, I think? What am I doing wrong?
    d
    • 2
    • 1
  • d

    Daniel Tweedy

    01/26/2022, 12:09 AM
    How are you supposed to do a date in Kotlin JS? I found a great way to do it in regular Kotlin but I don't appear to have access to that and every method in the kotlin.js seems to be depricated.
    e
    t
    l
    • 4
    • 5
  • s

    shaktiman_droid

    01/26/2022, 3:10 PM
    After upgrading to Kotlin
    1.6.10
    Should we commit this file
    kotlin-js-store/yarn.lock
    or
    gitignore
    it? Based on Github search, I see repos where they add it and some others where they do not keep it And there is this comment on this channel where @Oliver.O says that the
    intention is to track it on version control
    Can someone please clarify on this?
    o
    h
    • 3
    • 6
  • n

    Nikky

    01/26/2022, 5:22 PM
    after updating our codebase to use kotlin 1.6.10 dependencies the compilter seems to run into this error with IR:
    e: Could not find "org.jetbrains.kotlinx:kotlinx-serialization-json" in [C:\Users\nikky\AppData\Local\kotlin\daemon]
    has anyone seen this before ? more in :thread-please:
    o
    l
    • 3
    • 8
  • a

    ankushg

    01/26/2022, 5:29 PM
    Is anyone consuming Kotlin coroutines or Flows as callbacks from a real JS or TS (not Kotlin/JS) codebase? Any tips, hints, code snippets, etc? Trying to understand: • what scopes to use (is GlobalScope actually ok?!) • how folks are handling cancellations, • what a TS-friendly interface looks like that supports
    @JsExport
    , and • if there's any automated way to convert coroutines/flows to callbacks
    g
    • 2
    • 2
  • i

    Imran/Malic

    01/28/2022, 8:31 AM
    Hi I am trying to call a JS function from a dependency in Kotlin. The function
    toASCII
    here, my dependency definition looks like this
    jsMain {
          dependencies {
            api(npm("punycode", "2.1.1"))
            api(npm("urlencode", "1.1.0"))
            api(npm("buffer", "6.0.3"))
            api(npm("string_decoder", "1.3.0"))
          }
        }
    and the file punycode.kt looks like this:
    @JsModule("punycode")
    @JsNonModule
    @JsName("toASCII")
    public external val toASCII: (domain: String) -> String
    But it fails with:
    Uncaught TypeError: toASCII is not a function
      at /var/folders/qq/0zkljkj12jb9m0jnwftykyd00000gn/T/_karma_webpack_216427/commons.js:100744:17
      TypeError: toASCII is not a function
          at UriCompatibility.encodeDNSHost_6wfw3l_k$ (/var/folders/qq/0zkljkj12jb9m0jnwftykyd00000gn/T/_karma_webpack_216427/commons.js:100744:17)
          at _no_name_provided__274.invoke_6wfw3l_k$ (/var/folders/qq/0zkljkj12jb9m0jnwftykyd00000gn/T/_karma_webpack_216427/commons.js:97821:46)
    b
    • 2
    • 7
  • r

    Rohan Maity

    01/28/2022, 11:00 AM
    Can we create a mapping of private members of TS/JS file in kotlin adaper file ?
    b
    • 2
    • 16
  • r

    Rohan Maity

    01/29/2022, 11:28 AM
    Hello. folks Can I get some opinion on
    Kvision
    and
    kotlin react
    for building JS target in a multiplatform project ? I am looking for Stability here as well which could work in multiplatform environment ?
    r
    b
    +2
    • 5
    • 14
  • n

    Nolan

    01/31/2022, 4:50 PM
    i'm seeing some weird behavior with the js compiler. i'm wondering if i'm doing something wrong, or if it's an issue with the compiler. the behavior is the same with both IR and legacy compilers. code snippets in thread.
    :youtrack: 1
    r
    • 2
    • 5
  • l

    Luca

    02/01/2022, 5:38 AM
    Hi, can anyone here help me figure out how to create an instance of a js
    web3.eth.Contract
    ? Forgive me if this is a stupid question, as I am not the most familiar with js. I am more used to standard kotlin/OOP. I've figured out that an instance of
    web3.eth.Contract
    must be created where
    web3
    must be an actual instance of a
    Web3
    class (created
    new Web3(...)
    ) So I cannot simply create a contract instance by calling
    new Web3.eth.Contract(...)
    For example
    js("""new (new Web3(window.ethereum)).eth.Contract(JSON.parse('...'), '...' )""")
    will create a valid instance of a
    Contract
    But, when I attempt to create an instance of a kotlin defined contract:
    @JsModule("web3-eth-contract")
    @JsNonModule
    open external class Contract constructor(jsonInterface: Array<AbiItem>, address: String, options: ContractOptions)
    by calling
    val contract = Contract (jsonInterface = abis as Array<AbiItem>, address = adr)
    An instance of
    Contract
    IS created successfully, however it is worthless because the created contract seems to rely on a parent instance of
    Web3
    , (like in the first example I mentioned). How can I create a Contract class in kotlin, that is instantiated in the same way as
    js("""new (new Web3(window.ethereum)).eth.Contract(JSON.parse('...'), '...' )""")
    ?
    b
    • 2
    • 18
  • j

    janvladimirmostert

    02/02/2022, 12:55 PM
    in JavaScript string templates, there's a mechanism where if you pass the string template to a function without brackets, the string template is split into pieces
    function blah(...args) { console.log(args) }
    running this:
    blah`testing-${1}-${2}-${3}`
    I get a list of parts (separators between ${}), pre/post-fix and values
    0: (4) ['testing-', '-', '-', '', raw: Array(4)]
    1: 1
    2: 2
    3: 3
    length: 4
    Is there anything planned for Kotlin that would allows taking a String template and splitting it up like that at compile time? (similar to how to trimIndent() is processed at compile time, a compile time mechanism that can decompose a String template into its static and dynamic parts)
    val blah = """  
        testing-${1}-$var2-${var3 + 1}
    """.trimIndent()
    
    blah.decompose() // outputting the static parts, listOf("testing", "-", "-", "") and the dynamic parts, listOf(1, var2, { var3 + 1}())
    Just wondering how else one would replicate what lit-html, lit-element, uhtml and many of these JS frameworks are doing in pure JavaScript
    g
    • 2
    • 2
  • a

    ansman

    02/02/2022, 3:58 PM
    I’m on a mission to reduce the size of the bundle in my KMM project. I tried
    -Xir-property-lazy-initialization
    which doesn’t really do anything (actually increases our size). When paired with
    -Xir-per-module
    it reduces the size by 75%! However, this is only because it’s missing some imports. We use 3 libraries: • Kotlinx serialization • Kotlinx immutable collections • Kotlin stdlib I see 5 JS files as expected (two for serialization) in the build directory but the module JS file only contains this:
    }(module.exports, require('./kotlin-kotlin-stdlib-js-ir.js'), require('./kotlinx-serialization-kotlinx-serialization-core-js-ir.js')));
    So the bundle fails because one of the kotlinx serialization (the JSON part) and the kotlinx immutable is missing from the final, webpacked, JS file. Is this a bug or did I miss something?
    a
    • 2
    • 7
  • e

    Exerosis

    02/03/2022, 10:41 AM
    Is there a set of wrappers for nodejs official modules like
    net
    ? Or do I need to write my own to use those things?
    b
    h
    e
    • 4
    • 9
  • a

    andylamax

    02/04/2022, 7:55 PM
    I am trying to release a javascript library from our Multiplatform code base that will be targeting react native, my question is, which js target is closer to react native??
    Js(IR) { browser() }
    // or
    Js(IR) { nodejs() }
    b
    • 2
    • 9
  • b

    Big Chungus

    02/06/2022, 10:51 AM
    Has anyone figured how to declare kotlin externals for TS constructor reference type? Given TS
    class TSClassOne {
      constructor(someProp: string) {
        ...
      }
    }
    
    class TSClassTwo {
      TSClassOne: new (someProp: string) => TSClassOne
    }
    How to declare it in K/JS?
    external class TSClassOne(someProp: String)
    
    external class TSClassTwo {
      var TSClassOne: dynamic // actual: `new (someProp: string) => TSClassOne`, how do I tell kotlin that? `(String) -> TSClassOne` does not work as it's not invoking `new` call
    }
    ➕ 1
    t
    • 2
    • 4
  • k

    kk57

    02/07/2022, 12:40 AM
    Hello everyone, any idea about generating QR codes using Kotlin/JS?
    t
    • 2
    • 1
  • a

    Ayfri

    02/08/2022, 10:59 AM
    I just found out that there is a wrapper for TypeScript that is out on kotlin-wrapperes, if anyone needs it ! https://github.com/JetBrains/kotlin-wrappers/tree/master/kotlin-typescript
    😉 2
    :kotlin-intensifies: 8
    a
    b
    +3
    • 6
    • 23
  • s

    Sean Proctor

    02/08/2022, 2:40 PM
    I'm new to Kotlin/JS. I'm trying to import a TypeScript dependency. I added
    generateExternals=true
    to the gradle dependency and I get an error "Unresolved reference: JSX". Looking at the TypeScript definition, JSX is used but not imported. Is there a way to work around this?
    b
    • 2
    • 3
  • a

    Ayfri

    02/08/2022, 4:38 PM
    Hi, what should be the type of an optional property of an external interface ?
    a
    t
    b
    • 4
    • 10
  • m

    mbonnin

    02/09/2022, 2:22 PM
    I've been hit by this during jsTests:
    Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
    But my test needs to run longuer than 2000ms. Is there anything I can do to increase that timeout?
    :yes: 1
    t
    o
    • 3
    • 3
  • a

    andylamax

    02/09/2022, 5:01 PM
    One more for the day. Youtrack: https://youtrack.jetbrains.com/issue/KT-45727 Prelude Normally we'd like to have interfaces or abstract classes as our public API, and have underlying implementations private/internal to the module. Problem With kotlin multiplatform and kotlin js, this is still a huge challenge because despite using 
    @JsExport
    , properties of interfaces/abstract classes, are still mangled. It should be known that methods are not mangled at all Reproducer Reproducer can be found at ManglingImplementationTest
    • 1
    • 2
  • a

    andylamax

    02/09/2022, 11:29 PM
    At the moment,
    sealed class WatchMode {
        companion object {
            val DEFAULT: WatchMode = CASUALLY
        }
    }
    
    object EAGERLY : WatchMode()
    
    object CASUALLY : WatchMode()
    Generates the following type definitions
    class WatchMode {
        private constructor();
        readonly Companion: {
            readonly DEFAULT: live.WatchMode;
        };
    }
    const EAGERLY: {
    } & live.WatchMode;
    const CASUALLY: {
    } & live.WatchMode;
    This makes it impossible to get the value of
    WatchMode.DEFAULT
    from js/typescript impossible, because one would need to create an instance of
    WatchMode
    (whose constructor is private) and then get the
    DEFAULT
    property from
    Companion
    . Why is it a property, can't it be defined on
    WatchMode
    instead of it's
    prototype
    ? N;B. When the hierarchy is defined as show bellow
    sealed class WatchMode {
        companion object {
            val DEFAULT: WatchMode = CASUALLY
        }
    
        object EAGERLY : WatchMode()
    
        object CASUALLY : WatchMode()
    }
    The generated types are still unsable from js/typescript code. Funny thing is, classes work like a
    class WatchMode {
        private constructor();
        readonly Companion: {
            readonly DEFAULT: live.WatchMode;
        };
        readonly EAGERLY: {
        } & live.WatchMode;
        readonly CASUALLY: {
        } & live.WatchMode;
    }
    Is there a known workaround for this? or a reported ticket somehow?
    b
    s
    • 3
    • 3
  • s

    SirNapkin1334

    02/11/2022, 1:27 AM
    This is ridiculous, but I simply cannot figure out how to get a String from a specified codepoint in Kotlin/JS. I have many codepoints, and I need to make them into a String. And I can't find a way to do it in Kotlin/JS...in fact, all (two) constructors for
    String
    are deprecated in Kotlin/JS!
    e
    • 2
    • 9
  • a

    andylamax

    02/12/2022, 1:16 AM
    I am looking at the generated type definitions by
    1.6.20-M1
    . I gotta admint,
    @JsExport
    got the love it truly deserves Kudos to the whole team for such accomplishments. A lot of my issues (infact, all I have reported recently) have been already solved
    ❤️ 3
    a
    h
    g
    • 4
    • 12
Powered by Linen
Title
a

andylamax

02/12/2022, 1:16 AM
I am looking at the generated type definitions by
1.6.20-M1
. I gotta admint,
@JsExport
got the love it truly deserves Kudos to the whole team for such accomplishments. A lot of my issues (infact, all I have reported recently) have been already solved
❤️ 3
a

ankushg

02/12/2022, 1:54 AM
Excited to try it out!
a

andylamax

02/12/2022, 7:20 AM
Sadly, one thing makes the types definitions unusable. The generated file exposes companion objects on interfaces as a static getter. while at this moment, Typescript doesn't support static members/methods on interfaces
h

hfhbd

02/12/2022, 10:12 AM
one thing? what about this https://youtrack.jetbrains.com/issue/KT-51205? it makes exporting and using with typescript unusable :D
a

andylamax

02/12/2022, 9:12 PM
@hfhbd I am failing to reproduce your
external class is mapped to any
problem. Coz to me it works just fine
package battleground.problem

@JsExport
external interface User {
    var name: String
    var email: String
}

@JsExport
val pete: User = jso { }
Yields
export namespace battleground.problem {
    interface User {
        name: string;
        email: string;
    }
}
export namespace battleground.problem {
    const pete: battleground.problem.User;
}
Also, regarding to the promises problem, I don't have the problem because I don't use promises at all. I use a multiplatform of
Promise
called a
Later
, it can be found here https://github.com/aSoft-Ltd/foundation/tree/master/foundation-runtimes/later
👀 1
h

hfhbd

02/12/2022, 10:10 PM
Use a class
a

andylamax

02/13/2022, 2:32 AM
Use a class
This code
package battleground.problem

@JsExport
external class Promise<T>

@JsExport
val promise: Promise<Unit> = TODO()
generates the following types
export namespace battleground.problem {
    class Promise<T> {
        constructor();
    }
}
export namespace battleground.problem {
    const promise: battleground.problem.Promise<void>;
}
Are you sure you tried that on
1.6.20-M1
? However, I have noticed
kotlin.js.Promise<T>
is indeed exported as
any // kotlin.js.Promise<T>
While experimenting on this, I also noticed that
@JsExport
external class Promise<T> {
   companion object
}
Does not compile. For it to compile, you either remove the
companion object,
or
@JsExport
You can't seem to have both and make it work
h

hfhbd

02/13/2022, 11:10 AM
Using your own
Promise
class does not work with typescript interoperability, because it is not mapped to
js.Promise
.
a

andylamax

02/13/2022, 1:28 PM
not when you
copy
the type definition in
kotlin.js.Promise
into a file that is not inside a package. This is indeed a workaround though
g

Grégory Lureau

02/14/2022, 10:33 AM
What's the point to use
@JsExport
and
external
on the same class? It's just for testing 1.6.20-M1 or I'm missing something?
a

andylamax

02/14/2022, 10:49 AM
What's the point to use 
@JsExport
 and 
external
 on the same class?
If you just declare it as
external
the generated
.d.ts
won't include its definitions.
@JsExport
makes your external class types available in the generated
.d.ts
:thank-you: 1
View count: 4