https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
b

Big Chungus

03/22/2020, 5:27 PM
Any ideas how i can declare
expect
of the folowing JS class in common module so I could
typealias
it in JS module?
Copy code
class ExternalAPI {
  val important: dynamic
}
For context, I'm working on pushing KotlinJS browser API down to common module and implememnting it for WASM as well. To keep compatability with kotlinJS (and also some boilerplate code) I'd like to typealias all that to
org.w3c.*
packages on JS.
k

Kweku

03/23/2020, 3:52 PM
I'm assuming that ExternalApi is a class you jave created and that dynamic is the Js dependency You can make a expect class NAME_HEREin common then use actual typealias NAME_HERE = dynamic. Then in common expect class ExternalApi { val important : NAME_HERE } I also think interfaces can be used in place of expect/ actual
b

Big Chungus

03/23/2020, 3:55 PM
That doesn't work. I get
Type alias expands to dynamic, which is not a class, an interface, or an object
having
Copy code
expect class Dynamic

actual typealias Dynamic = dynamic
k

Kweku

03/23/2020, 3:55 PM
What is dynamic?
b

Big Chungus

03/23/2020, 3:55 PM
dynamic is KotlinJS keyword