269 questions
1
vote
0
answers
99
views
Kotlin JS and Lenses
I need lenses on nested data classes in Kotlin for the JavaScript target.
Since Arrow is not available for KotlinJS: Are there any libraries, examples, gists, available? Or has at least somebody an ...
1
vote
1
answer
1k
views
Kotlin js isn't picking up dependencies from gradle implementation(npm section in build file
I've got a Kotlin JS project and I'm trying to add some npm dependencies via Gradle. My understanding is that I have to add the npm deps to the the dependencies of this source set, like so:
plugins {
...
0
votes
2
answers
210
views
In Kotlin JS calling getHours on a date gives TypeError: date.getHours is not a function
Hopefully this is a common issue that someone can help me with ?
I've got a data class that has a kotlin,js.Date on it. If I print out the value of it via console.log I get:
2019-12-29T13:30:00.000+...
1
vote
1
answer
1k
views
Kotlin multiplatform node.js project fails due to "Error: Cannot find module '...'"
I have built a Kotlin multiplatform library and published it to bintray. When trying to include it in a sample node.js application it will be able to find the dependency, but compiling will fail with ...
3
votes
1
answer
598
views
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 ...
2
votes
1
answer
2k
views
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:...
1
vote
1
answer
85
views
How do I obtain Kotlin/JS dependency files
As of Kotlin 1.3.41, the kotlin js compiler would produce the js files for dependencies (e.g. the standard lib kotlin.js). In Kotlin 1.3.50 and 1.3.60, these dependencies are no longer produced.
How ...
1
vote
0
answers
147
views
gradle recipe/archetype/generators for multi-modules kotlin nodejs backend and reactjs frontend
I'm missing or looking for is something similar to a maven archetype or a yoeman generator. I need a starter project with best practices with the basic plumbing and scaffolding in place which i can ...
0
votes
0
answers
568
views
Redirect to another web page in Kotlin Web Front End development
I am trying to redirect to another web page in Kotlin for Web Front End development. I have wrote this code to achieve this:
window.location.href = "adduser1.html"
But if I write this code then, the ...
1
vote
1
answer
201
views
Kotlin JS doesn't add "new" keyword where needed
I am creating interactive infographics using Google Charts and Kotlin JS. This is snippet from Quick Start Page.
var data = new google.visualization.DataTable();
<..>
var chart = new google....
0
votes
1
answer
88
views
How to depend on a maven local jar when using create-react-kotlin-app https://github.com/JetBrains/create-react-kotlin-app
I want to build a frontend in kotlin/react.
I want it to be able to depend on common artefacts written in kotlin.
These artefacts will be in my local maven repo.
How do I reference these in package....
1
vote
1
answer
88
views
Firebase Email-Password Authentication using Kotlin in Web Front-End
I am trying to implement Firebase Email-Password Authentication using Kotlin in Web Front-End. But I think we can't do it using Kotlin as Firebase Authentication for Web only supports JS as per the ...
0
votes
1
answer
276
views
Setting up Netty (or Spark) to provide the output of kotlin-js module as static
I try to create a whole-stack project using Kotlin. As multiplatform projects are experimental in Kotlin, there is not much information available, so I tried to start from the project skeleton of IDEA ...
2
votes
1
answer
356
views
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:
...
1
vote
2
answers
650
views
Disabling Node.js download in KotlinJS Gradle plugin
The version of Node.js that KotlinJS downloads (as of 1.3.40+) seems not to work in Alpine Linux. The docker image I'm using already has Node baked into it, so there's no reason not to use that one.
...
1
vote
1
answer
580
views
How can I test UI with kotlin JS? (e.g. have an element on a page)
I want to testing js project, written on kotlin js.
For example, test, which elements added after click on btn.
How can I do it?
Such as
@Test
fun myTest() {
when{
window.onLoad().await()
...
2
votes
1
answer
1k
views
Using Kotlin standard library from JavaScript
I have a Kotlin function written that consumes a List<String>. The function has an annotation with @JsName so that I can call this function from JavaScript. I cannot determine though what I am ...
5
votes
3
answers
2k
views
How do I call JS functions like setTimeout in Kotlin when not targeting browsers
Do I have to define them externally like so:
external fun setTimeout(exec: suspend () -> Unit, timout: Int)
Or is there something in the stdlib I can use?
I can't use kotlin.browser.window....
7
votes
1
answer
5k
views
Can I use coroutines in Kotlin when targeting JavaScript?
Is it possible to launch any coroutines when targeting JavaScript?
It doesn't like any of the usual ways like async{}
Example on: https://github.com/thigg/no-kotlinx-in-js
1
vote
1
answer
172
views
How to have a KotlinJS module, where the business logic is tested with JUnit?
Bear with me, I don't yet see the whole picture of how multiplatform works.
What I want to achieve is have some business logic, which at the end is compiled into a a js file that I can use in an HTML,...
9
votes
2
answers
757
views
Why Does Kotlin/JS Return Different Results for === Than Does Kotlin/JVM?
Given this code:
val value = "something"
println(value.toUpperCase().toLowerCase() == value) // prints true
println(value.toUpperCase().toLowerCase() === value) // prints false
On Kotlin/JVM 1.3....
1
vote
1
answer
348
views
Having trouble trying to make an circle move on a canvas element, while programming with JS compiled Kotlin
I am building a very simple web-based 'breakout', and I have run into trouble when trying to make the ball move on the canvas element. I do have the game up and running in javascript. Thing is, I am ...
2
votes
3
answers
1k
views
Can I get exception stacktrace in kotlin-js?
I've been writing simple web-frontend for application with kotlin-js and faced with a problem of exception handling.
As I see, there is no API to get exception stacktrace: https://kotlinlang.org/api/...
3
votes
3
answers
2k
views
Kotlin/JS external declaration - "Name contains illegal chars that can't appear in JavaScript identifier"
EDIT: This is not supported yet and tracked on Kotlin YouTrack
I'm trying to write a Kotlin external declaration matching the following Typescript interface (this is valid TS to represent JavaScript ...
2
votes
1
answer
302
views
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 = "${...
0
votes
1
answer
187
views
Error getting while building react kotlin app using IntelliJ
I've created a simple react app using create-react-kotlin-app. After successful npm start, I tried to get a build of the project using IntelliJ IDEA's Build -> Build Project, but it fails stating
...
2
votes
1
answer
386
views
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 ...
0
votes
1
answer
541
views
KotlinJs - simple HTTP GET without Dynamic Type functionality
I'm totally new in KotlinJs and I wanted to check its potential in server-less service development.
I decided to start with calling external API with HTTP GET method using XMLHttpRequest() suggested ...
3
votes
1
answer
607
views
How to import standard JSON parsing library in Kotlin
I want to use kotlin.js parse, but I don't know how to import it.
I tried
import org.jetbrains.kotlin.js.parser.sourcemaps.*;
but it didn't include JSON parse
0
votes
1
answer
1k
views
How to properly use JSON.parse in kotlinjs with enums?
During my fresh adventures with kotlin-react I hit a hard stop when trying to parse some data from my backend which contains enum values.
Spring-Boot sends the object in JSON form like this:
{
"id":...
3
votes
1
answer
1k
views
Using pow in KotlinJS in Intellij
There is a library called kotlin.math which contains a method pow:
import kotlin.math.pow
val factor = pow(10.0, 2)
print(factor)
and result:
100.0
However Intellij is not registering that I have ...
1
vote
1
answer
281
views
How to create kotlin.collections.Set from plain JavaScript array?
I'm trying to call from plain JavaScript into a Kotlin module that has been compiled into JavaScript. One of the Kotlin methods inside the module requires a kotlin.collections.Set to be passed. How ...
6
votes
2
answers
3k
views
Load resource file (json) in kotlin js
Given this code, where should I place the file.json to be able to be found in the runtime?
// path: src/main/kotlin/Server.kt
fun main() {
val serviceAccount = require("file.json")
}
I tried place ...
2
votes
2
answers
2k
views
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 ...
9
votes
3
answers
1k
views
How to define a global js function in Kotlin?
Every function and variable that I create in KotlinJs project gets into a module. But I need to define some functions in global scope.
I use p5js library (pure js). It allows user to define event ...
4
votes
1
answer
428
views
Kotlin 1.3.20 with Gradle 5.1.1 compileKotlin2Js execute hot reload
In Kotlin 1.3.20 and Gradle 4.10.2, it is possible to hot reload js files with the following in Gradle:
task watch {
inputs.files 'src/main'
doLast {
compileKotlin2Js.execute()
}
}...
0
votes
1
answer
300
views
Include js dependencies in kotlin-js
I want to incude javascript dependencies in my kotlinjs project. (concret : https://airbnb.io/polyglot.js/ but others as well).
My kotlinjs Project is a gradle Project, developed in IntelliJ Idea.
...
0
votes
2
answers
503
views
Which import do i require to make use of hashrouter in KotlinJS React App
I'm bootstrapping a KotlinJS + React application using the following steps:
npm install -g create-react-kotlin-app
create-react-kotlin-app frontend
cd frontend
npm install kotlinx-coroutines-core
npm ...
2
votes
1
answer
498
views
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 ...
15
votes
2
answers
11k
views
How to compile Kotlin into TypeScript?
I have a JavaScript build in my Kotlin project.
How can I produce full TypeScript code instead of JavaScript?
I use Maven; but if you have a Gradle solution, I'm interested.
1
vote
1
answer
94
views
How do i get access to Facebooks javascript api in a Kotlin React project?
I have a project using "kotlinFrontend" to create a really nice react front end written in kotlin. How do i get access to the facebook js sdk (it is usually done withing script tags)
I have this code ...
2
votes
1
answer
513
views
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/...
2
votes
2
answers
1k
views
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 ...
6
votes
3
answers
673
views
Gradle doesn't emit kotlin.js
I'm trying to compile my Kotlin app and set of Kotlin libraries to JavaScript. I've got that working well, but when I try to run it it can't find kotlin.js.
So what's going on here? When I compile ...
2
votes
2
answers
2k
views
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 ...
0
votes
1
answer
2k
views
Could not find method srcDirs() for arguments on SourceSet container of type org.gradle.api.internal.tasks.DefaultSourceSetContainer
I'm trying to compile my Kotlin app and set of Kotlin libraries to JavaScript. I've got that working well, but when I try to run it, it can't find kotlin.js. To remedy this, I tried changing my build....
18
votes
1
answer
14k
views
How is Kotlin specifically compiled?
I'm trying to understand the journey Kotlin source code goes through when it is compiled. The documentation states
When targeting the JVM, Kotlin produces Java compatible bytecode. When targeting ...
0
votes
2
answers
4k
views
Error: Could not find or load main class MainKt in IntelliJ
I'm using IntelliJ.
I can run Java or Kotlin project without any issue but
I can't build Kotlin-JS project
I have the error Error: Could not find or load main class MainKt
My IntelliJ information
...
0
votes
1
answer
78
views
Create React apps using Kotlin and External
I'm trying to wrap this simple API: https://github.com/github-tools/github, just for study purpose. So, I created this external classes:
package index
import com.github.jesty.githubapi.Result
import ...
1
vote
1
answer
698
views
Render html with kotlin-react
Been writing a lot of React with kotlin using the front end plugin. It has been amazing thus far doing nothing overly exotic. I am now trying to render stored HTML in my react component.
I am ...