//common
expect class PlatformElement
//android
//works
actual typealias PlatformElement = View
//js
//error:The following declaration is incompatible because modality is different
actual typealias PlatformElement = HTMLElement
I found HTMLElement is
abstract
, so it fails. But I won't use the constrcutor, I just want to declare the type, so what should I do ?
j
jw
07/03/2023, 2:11 PM
as long as you don't expose a constructor in common you can suppress the error and it'll be fine.
another option is to use a value class on JS to "wrap" HTMLElement
a
Ayla
07/03/2023, 2:29 PM
It works, thank you!
l
Luv Kumar
07/20/2025, 11:54 AM
Hi @jw@Ayla i am also facing a similar issue in
Copy code
// commonMain
expect class PlatformStream
// iosMain
actual typealias PlatformStream = NSInputStream
// androidMain
actual typealias PlatformStream = InputStream
could you guys share how can i suppress it ? i tried something like
Copy code
@Suppress("ACTUAL_WITHOUT_EXPECT")
actual typealias PlatformReadStream = InputStream
doing above idea removes the compilation warning but doing
./gradlew build -x check
still give following error `Expect declaration
PlatformReadStream
is incompatible with actual
PlatformReadStream
because modality is different. Expect declaration modality is 'final'. Actual declaration modality is 'abstract'`