I had a lot of trouble getting that to work, mostl...
# multiplatform
d
I had a lot of trouble getting that to work, mostly because of
actual typealias
not working correctly yet. That makes it impossible to use e.g.
UUID
in your domain objects.
l
@diesieben07 try this and post your feedback please common:
Copy code
package your.domain.package

expect class UUID

expect fun randomUUID() : UUID
jvm:
Copy code
package your.domain.package

actual typealias UUID = java.util.UUID

actual fun randomUUID () : UUID = java.util.UUID.randomUUID()
js:
Copy code
package your.domain.package

import ext.js.npm.uuidv4

actual class UUID

actual fun randomUUID() : UUID = uuidv4()
Copy code
@file:JsModule("uuid")
package ext.js.npm

@JsName("v4")
external fun uuidv4() : dynamic
package.json
Copy code
"dependencies": {
    "uuid": "^3.2.1",
...
  }
d
It's broken in the IDE, various things will be marked as errors even though they aren't. It's already reported on Youtrack.
l
it is work in my case, what structure of your project?
what version of IDEA and kotlin you use? do you build with gradle?
d
Your case works, but as soon as you try to do anything more elaborate (e.g. have a method in common that takes a
UUID
and call that method from the JVM module) you get all kinds of errors. Using 2018.1.1 and Kotlin 1.2.31. I build with gradle. Like I said, this bug is already reported and acknowledged: https://youtrack.jetbrains.com/issue/KT-22868
l
it is just IDEA problem, gradle builds it successfully
d
I know. I said that above 😉
l
oh, you are right 🙂