julien lengrand-lambert
03/30/2022, 2:14 PMasync
functions into Kotlin, some pointers would be greatly appreciated because I'm early missing something (https://stackoverflow.com/questions/71678834/how-do-i-import-and-use-an-async-js-function-in-kotlin-js)julien lengrand-lambert
03/30/2022, 9:31 PMdata class FirebaseUser(
val email: String,
val uid: String,
val accessToken: String,
)
@JsModule("@jlengrand/firebase-ports")
@JsNonModule
external object FirebasePorts{
fun logIn() : Promise<FirebaseUser>
}
var user : FirebaseUser? by mutableStateOf(null)
Button(attrs = {
onClick {
console.log(JSON.stringify(user))
console.log(user)
console.log(user!!.uid)
}
}) {
When doing this, ths results are as following :
{"accessToken":"exampleToken","email":"<mailto:example@gmail.com|example@gmail.com>","uid":"example"}
{accessToken:exampleToken,email:example@gmail.com,uid:example}
undefined
Is that expected, and how do I fix this? I mean, the value is there clearlyjulien lengrand-lambert
03/31/2022, 8:18 AMUncaught TypeError: ensureNotNull(...).iterator_0_k$ is not a function
errors (same for `ìsEmpty`and any other idiomatic List function).
external interface FirestoreMessage{
val id: String
val content: String
}
@JsModule("@jlengrand/firebase-ports")
@JsNonModule
external object FirebasePorts{
fun logIn() : Promise<FirebaseUser>
fun logOut()
fun saveMessage(uid: String, message: String)
fun getMessages(uid: String) : Promise<List<FirestoreMessage>>
}
Do you have a reference on how to use lists in external interfaces by any chance?julien lengrand-lambert
03/31/2022, 8:18 AMandylamax
04/01/2022, 12:01 AMLong
object is not mapped to Javascript's BigInt
?
2. Is there a reason why Kotlin Number
is not mapped to Javascript's Number
3. Is there a reason why Kotlin Map
and Set
are not mapped to Javascript's Map
and Set
respectively?julien lengrand-lambert
04/01/2022, 1:39 PMimport { doc, onSnapshot } from "firebase/firestore";
const unsub = onSnapshot(doc(db, "cities", "SF"), (doc) => {
console.log("Current data: ", doc.data());
});
This snippet listens to realtime changes in firestore and triggers the callback function then.
I literally have no clear idea how to bind this with my Kotlin. The main issue I see is that I would need to pass a function as input to the binding, with access to the kotlin side data 🧐grahamborland
04/01/2022, 3:01 PMLong
and Number
. I have this Kotlin code:
@JsExport
fun isNegative(amount: Long) : Boolean = amount < 0L
which fails at runtime in Typescript because
TypeError: amount.compareTo_n4fqi2_k$ is not a function
Can someone gently guide me towards what kind of solutions I should be investigating? Should I just not use Long
in the Kotlin code, or should I be adding some conversion logic somewhere?Ayfri
04/01/2022, 5:29 PMMichael Friend
04/01/2022, 7:28 PMGopal S Akshintala
04/03/2022, 1:03 PMAkram Bensalem
04/03/2022, 4:35 PMLuc Girardin
04/04/2022, 10:54 AMbashor
04/04/2022, 1:29 PMandylamax
04/04/2022, 9:00 PMTask :jsBrowserTest
java.lang.IllegalStateException: command '/home/runner/.gradle/nodejs/node-v16.13.0-linux-x64/bin/node' exited with errors (exit code: 134)
After bumping to 1.6.20?
I am getting this on CI and my machine as wellMichal Klimczak
04/06/2022, 7:59 PMprivate suspend inline fun <reified T> fetch(
url: String,
state: ObservableValue<Collection<T>>
) {
val response1 = client.get(url).body<List<T>>(typeInfo<List<T>>())
val response2 : List<T> = client.get(url).body()
val type = typeOf<T>()
}
neither response1, nor response2 is able to properly derive the generic type, even though it's reified.
TypeInfo(type=class List, reifiedType=[object Object], kotlinType=null)
And calling typeOf fails with a weird " This marker function should never been called. Looks like compiler did not eliminate it properly. Please, report an issue if you caught this exception."
When the type is provided directly, everything works fine, obviously (kotlinType
is properly defined). Is that not possible at all, even with reified type? Can I create a KType
for List<T>
?
Kotlin 1.6.10shaktiman_droid
04/07/2022, 4:13 PM1.6.20
, in the generated typescript file, I noticed the addition of __DoNotUserIt
of type __doNotImplementIt
Does anyone know reason behind it? It creates an issue if we have to implement that interface on TypeScript
app side.
Kotlin Code
@JsExport
interface GreetingInterface {
val platform: String
fun greeting(): String
}
Generated .d.ts
file
declare const __doNotImplementIt: unique symbol
type __doNotImplementIt = typeof __doNotImplementIt
export namespace <PACKAGE> {
interface GreetingInterface {
readonly platform: string;
greeting(): string;
readonly __doNotUseIt: __doNotImplementIt; <----- What and why is this here?
}
}
TypeScript App Usage (example.ts)
class Greeting implements GreetingInterface {
platform: string = "TypeScript"
greeting(): string {
return "this is greeting from " + this.platform;
}
__doNotUseIt: typeof sdk.__doNotImplementIt; <----- What to do here apart from adding `!` so compiler doesn't complain
}
Marc Knaup
04/09/2022, 8:16 PMfun main()
in modules compiled with -Xir-per-module
are no longer executed automatically when the module is loaded.
How can I make that work again?Marc Knaup
04/10/2022, 10:10 AMReuben F
04/10/2022, 6:54 PMJulius
04/10/2022, 10:52 PMspierce7
04/14/2022, 4:18 PMDerek Wong
04/19/2022, 8:10 PMHakon Grotte
04/20/2022, 6:36 AMMoritz Hofmeister
04/21/2022, 12:58 PMAyfri
04/21/2022, 1:54 PMTask 'wrapper' not found in project ':packages:my-submodule'.
, I have
tasks.wrapper {
gradleVersion = "7.4.2"
}
In my root build.gradle.kts
.
I also configured my modules to uses wrapper from the wrapper
task (image)ansman
04/21/2022, 3:57 PMCollection.size
isn’t defined at runtime and calls to it returns undefined
which in turn causes most things that uses collections to fail. I’m guessing it will be very hard for me to have a reproducer since this can’t possibly happen in most cases or the tests for the compiler would have caught them. Does this sound familiar to anyone else?bod
04/21/2022, 4:31 PMimplementation(npm("express", "4.17.3"))
And declared this external:
@file:JsModule("express")
@file:JsNonModule
package express
external fun express(): dynamic
But calling express()
in my code gives me:
TypeError: express_0 is not a function
Any idea why it's named express_0
in the generated js? 🤔Derek Wong
04/21/2022, 8:53 PMget created(): any/* kotlinx.datetime.Instant */;
In previous versions I believe these would use undefined named types like this:
get created(): kotlinx.datetime.Instant
The issue with the explicit “any” type is that I’m no longer able to use my own supplemental typescript definitions for Webstorm to pick up like this:
export namespace kotlinx.datetime {
export class Instant {
toDate(): Date
__proto__: any
}
}
I’m sure there is a good reason for switching over to the “any” type for unexported types, but is there any possibility of a flag to generate the named unknown types we had before?
Being able to use supplemental typings is still pretty handy since a lot of the kotlin libraries are still not exportable. Also open to any alternatives to the approach I was using to add typings that works with the new export format if anyone knows.mike.holler
04/21/2022, 9:51 PMexternal
declarations for the following signatures?
flatbuffers.Builder = function(opt_initial_size) { ... }
flatbuffers.Builder.prototype.clear = function() { ... }
What I have tried is:
@file:JsModule("flatbuffers")
@file:JsNonModule
package flatbuffers
external class Builder(initialSize: Int) {
fun clear()
}
But I get an error:
TypeError: Builder is not a constructor
bod
04/22/2022, 6:25 AMAsyncIterator
. For instance here's something in JS :
myAsyncIterator = async function* () {
for await (const word of ["one", "two", "three"]) {
yield { count: word };
}
}
Any idea how to write an equivalent in Kotlin?bod
04/22/2022, 6:25 AMAsyncIterator
. For instance here's something in JS :
myAsyncIterator = async function* () {
for await (const word of ["one", "two", "three"]) {
yield { count: word };
}
}
Any idea how to write an equivalent in Kotlin?turansky
04/22/2022, 11:57 AMAsyncIterator
contract in lib.dom.d.ts
to write effective addapterbod
04/22/2022, 12:36 PMturansky
04/22/2022, 10:39 PMI can’t seem to find it there 🤔Do you use IDEA?
bod
04/23/2022, 8:06 AMturansky
04/23/2022, 7:00 PMbod
04/23/2022, 7:05 PMturansky
04/23/2022, 7:14 PMVery interesting! I wonder why I can’t see this but I’ll investigate1. Create JS file 2. Write
Symbol.asyncIterator
3. Cmd
+ click on asyncIterator
4. PROFITbod
04/24/2022, 12:27 PMturansky
04/24/2022, 6:23 PMbod
04/27/2022, 8:16 AMdynamic
so it's weakly typed, but that's ok for my use-caseturansky
04/27/2022, 9:31 AMSergei Grishchenko
04/27/2022, 10:14 AMfunction*
) relates to suspend
in Kotlin but I think we (wrappers developers) need some invent some wrappers and strategies to make integration to generators more seamless, example of such integration is
public suspend fun <T> kotlin.js.Promise<T>.await(): T { /* compiled code */ }
from kotlinx.coroutines
bod
04/27/2022, 12:34 PM