Questions tagged [kotlin-js]

281 questions
1
vote
1 answer

Kotlin/JS fails to build inside of Docker because of backslashes in package.json

I have a multi-project gradle build that I'm trying to build inside of docker. One of the projects is a Kotlin multiplatform project that builds to JVM and JS. Building the library is fine on my Windows machine, but I get an error when building from…
1
vote
1 answer

Module not found: Error: Can't resolve 'firebase/app' in Kotlin/JS

In a Kotlin/JS project, I have added the Firebase dependency - implementation(npm("firebase", "9.14.0")) Added the external declaration file: @file:JsModule("firebase/app") @file:JsNonModule @file:Suppress( "INTERFACE_WITH_SUPERCLASS", …
Avijit Karmakar
  • 8,890
  • 6
  • 44
  • 59
1
vote
1 answer

Typescript: Exporting Enum classes to JS produces compilation error

I trying to export Kotlin Enum classes to JS @OptIn(ExperimentalJsExport::class) @JsExport enum class interEnum { SAMPLE } But in Angular Project, after importing as NPM module, the respective TS block in module_name.d.ts throws error during…
RagAnt
  • 1,064
  • 2
  • 17
  • 35
1
vote
0 answers

View exceptions in Kotlin Compose for web

I'm playing with jetpack compose for web to see if I suits my needs. The development is great, however, when an error (exception) occurs the logs are displayed in the browser in an not developer-friendly way. I attach screenshot: Is there a way to…
Mateu
  • 2,636
  • 6
  • 36
  • 54
1
vote
2 answers

javascript as target in kotlin multiplatform library

I'm building a Kotlin multiplatform library. One of the targets in this project is javascript. In the source set I have added a dependency like this: val jsMain by getting { dependencies { implementation(npm("libphonenumber-js",…
1
vote
1 answer

​ [Kotlin/JS with React] Is there a way to use React Portals?

The function I suppose I should use is: createPortal( children: ReactNode?, container: Element, key: Key? = definedExternally, ) What I tried is doing something like this: A component (Modal.kt) val Modal = FC { p { …
1
vote
0 answers

KotlinJS with React-Router-Dom, How to use the location state?

I have a kotlin multiplatform project that has a jvm server and a KotlinJS client that uses kotlin-wrappers such us kotlin-react and react-router-dom. I recently updated the wrappers version and they changed the way that the NavigateOptions' state…
1
vote
0 answers

Kotlin/JS package is empty

In the following project: https://github.com/MarcinMoskala/AnkiMarkdown When I push a package to NPM, it seems empty. No binary code. I do export a single…
MarcinM
  • 428
  • 7
  • 15
1
vote
0 answers

How to declare external typescript types in kotlin

I need to access a Typescript library (react-admin) from kotlin-js In particular this types definitions https://github.com/marmelab/react-admin/blob/master/packages/ra-core/src/types.ts How do I declare in kotlinjs for example the following types…
frhack
  • 4,862
  • 2
  • 28
  • 25
1
vote
1 answer

Use enforcePlatform in Kotlin multiplatform

How can I use enforcePlatform function in Kotlin multiplatform? This works well: plugins { kotlin("js") } dependencies { fun kotlinw(target: String): String = "org.jetbrains.kotlin-wrappers:kotlin-$target" …
Jordi
  • 2,055
  • 1
  • 16
  • 34
1
vote
2 answers

How to define external functions that return type unions in Kotlin/JS?

I'm writing external declarations for LeafletJS 1.8.0, a JavaScript library, using Kotlin 1.6.21. The Polyline class has a function, getLatLngs() that can return any of these types: Array Array> Array>> Of…
aSemy
  • 5,485
  • 2
  • 25
  • 51
1
vote
0 answers

Kotlin's Dukat is generating code with a tons of error

Here's my current gradle.build.kts plugins { kotlin("js") version "1.5.31" } group = "me.fan87" version = "1.0-SNAPSHOT" repositories { jcenter() mavenCentral() } dependencies { …
fan87
  • 11
  • 2
1
vote
0 answers

Kotlin/JS - pretty print HTML/XML

I'm writing a unit test where I'd like to compare some HTML that's generated by a library (KVision) to some expected HTML. To do this I wanted to format the HTML so it's laid out nicely, and the expected and actual HTML can be compared…
aSemy
  • 5,485
  • 2
  • 25
  • 51
1
vote
0 answers

Kotlin Multiplatform (IR js): how to simply use kotlinx.collections from js ? [Mangling Issue]

At first sight, it seems easy using kotlin collections from js. Because kotlin multiplatform and its libraries (kotlinx.collections, etc) generate shared libraries that are interoperable between both js and kotlin. If we call new ArrayList() from…
nicolidz
  • 462
  • 4
  • 10
1
vote
1 answer

Strange behaviour of lambdas that return `dynamic` in Kotlin/JS interop

I want to write a lambda function that returns dynamic that ends with an assignment operation. The following does not type-check: var a: Int? val f: () -> dynamic = { a = 42 } Note: this example is somewhat artificial for the purposes of making…
lsparki
  • 113
  • 5