Questions tagged [kotlin-js]
281 questions
2
votes
1 answer
Is it possible to call kotlin's js function with an interpolated string template?
Right now, IntellJ is showing a red squiggly line saying: Argument must be a string constant
private fun fromEnv(name: String) {
return js("process.env[${name}]") as Unit
}
I've searched but I have not found any similar question.
Solved by…

Richard Domingo
- 379
- 1
- 19
2
votes
1 answer
Change item's data type in a List or array in Kotlin
how can i change item's data type in arrays or lists in kotlin ?
i found a usual way but i need an easier and faster and better way to change data type of an array :)
fun typeChanger (data:MutableList): DoubleArray {
val result =…

Mahdi Safarmohammadloo
- 508
- 6
- 20
2
votes
1 answer
Using `google-maps-react` in Kotlin JS/React project
I'm trying to use google-maps-react component as part of a Kotlin JS project but running in to some issues with how the way it's used maps to Kotlin. I have following google-maps-react.kt file so far:
@file:JsModule("google-maps-react")
package…

John O'Reilly
- 10,000
- 4
- 41
- 63
2
votes
1 answer
Using Kotlin standard library from JavaScript
I have a Kotlin function written that consumes a List. The function has an annotation with @JsName so that I can call this function from JavaScript. I cannot determine though what I am supposed to pass into this function. Passing an…

Vance T
- 513
- 2
- 5
- 15
2
votes
1 answer
How extend task provided by plugin?
I have kotlin2js plugin with task compileKotlin2Js. I configure it like this:
val compileKotlin2Js: Kotlin2JsCompile by tasks
compileKotlin2Js.kotlinOptions {
main = "call"
outputFile = "${projectDir}/build/app.js"
}
Now I want to create…

leaf
- 87
- 11
2
votes
1 answer
Using Vaadin components in a kotlin js project
This question is about a Kotlin JS project which uses the Kotlin Frontend Plugin.
I want to use some UI components from the Vaadin Components library.
I have two questions about this:
(1) What would be the best way to include web components in…

monk
- 640
- 1
- 5
- 17
2
votes
2 answers
writing nodejs applications in kotlin with intellij idea ce
I am trying to develop a Nodejs application using Kotlin 1.3.11 using the IntelliJ IDEA CE development environment. Unfortunately I haven't made any progress towards a running application. To ensure everything is setup correctly I want to print out…

steambrew
- 23
- 4
2
votes
1 answer
Kotlin: Spread operator on calling JavaScript method
I try to write a type-safe wrapper for a JavaScript library.
I need to call a method from JavaScript with variable arguments
(e.g. method(args...)).
The Kotlin fun for this should work with variable arguments, too.
Because Kotlin supports a spread…

Felix Stupp
- 81
- 8
2
votes
1 answer
How to pack javascript dependencies into Kotlin JS project JAR?
I am making some kotlin JS wrappers for Firebase Javascript SDK. So I created the project with the external keyword and @file:JsModule annotation, something like that:
@file:JsModule("@firebase/messaging-types")
package…

Allan Veloso
- 5,823
- 1
- 38
- 36
2
votes
2 answers
What is the idiomatic way of creating instance of external interface in Kotlin JS
Example:
In @material-ui/core/createMuiTheme.d.ts there are a few interfaces defined, e.g. ThemeOptions and Theme
It's possible to generate koltin bindings using ts2kt and it allows using createMuiTheme function to create Theme from ThemeOptions,…

Sam
- 1,652
- 17
- 25
2
votes
2 answers
Js module build fails on Kotlin multiplatform project
Build fails with error messages:
ERROR in ./output.js Module not found: Error: Can't resolve 'common'
in 'C:\Users\User\Documents\MultiPlatformTodo\web\web' @ ./output.js
340:91-108
ERROR in ./output.js Module not found: Error: Can't resolve…

Edson Menegatti
- 4,006
- 2
- 25
- 40
2
votes
3 answers
How to JavaScript object to Kotlin class?
I want to get a JavaScript object loaded into a Kotlin class.
As a safety check, I need to verify that the Kotlin object is actually the class I’ve created because some JavaScript code parts are not my design.
I need the JavaScript to return…

iHad 169
- 1,267
- 1
- 10
- 16
2
votes
0 answers
How to run a full stack application using kotlin?
I want to run a full stack web application with Kotlin + react + reduce. I tried to use the create-react-kotlin-app app but it does not work with reduce.
Now I am trying to use the Thinkter: A Kotlin Full-stack Application Example. I download the…

dilvan
- 2,109
- 2
- 20
- 32
2
votes
1 answer
Different behavior of KClass between Kotlin-jvm and Kotlin-js
I wrote some kotlin code to show a difference of behavior between the execution on jvm and in js. How could I fix this?
This equality: booleanKClass == genericKclass
is true for JVM
but false for JS
I’m going to paste the code followed by the output…

Jako
- 2,489
- 3
- 28
- 38
2
votes
1 answer
Kotlin js globally handling for unhandled exceptions
Is there a proper way in Kotlin-js to globally catch unhandled exception?
I have made a general attempt with window.onerror (see below).
The only reported error is on non_existing_function2, but nothing is reported for the other 2 cases.
Any…

Jako
- 2,489
- 3
- 28
- 38