Piotr Krzemiński
10/02/2025, 8:48 AMinternal actual fun isInteger(value: Any): Boolean =
js("return Number.isInteger(value)")
but I'm getting Type 'Any' cannot be used as value parameter type of JS interop function. Only external, primitive, string, and function types are supported in Kotlin/Wasm JS interop.. Tried also with Number as the arg type. Is there an idiomatic way of dealing with these? Maybe even the function's body can be implemented in a better way, but first I need to sort out the function's signature being invalidRobert Jaros
10/02/2025, 8:54 AMPiotr Krzemiński
10/02/2025, 8:55 AMexpect functionRobert Jaros
10/02/2025, 8:56 AMPiotr Krzemiński
10/02/2025, 8:57 AMactual function for WasmRobert Jaros
10/02/2025, 9:01 AMPiotr Krzemiński
10/02/2025, 9:02 AMfun isInteger(value: Any) works fine, what's problematic is *actual* fun isInteger(value: ???)Piotr Krzemiński
10/02/2025, 9:03 AMRobert Jaros
10/02/2025, 9:03 AMRobert Jaros
10/02/2025, 9:04 AMAny parameterRobert Jaros
10/02/2025, 9:04 AMJsAnyRobert Jaros
10/02/2025, 9:05 AMAny to JsAny, but as you can see it doesn't work as you could expect (calling with 5 returns false).Robert Jaros
10/02/2025, 9:06 AMreturn in js()Piotr Krzemiński
10/02/2025, 9:09 AMPiotr Krzemiński
10/02/2025, 9:09 AMprivate fun isIntegerPrv(value: JsAny): Boolean = js("Number.isInteger(new Number(value))")
but got
Unhandled JavaScript exception: can't convert value to numberRobert Jaros
10/02/2025, 9:12 AMRobert Jaros
10/02/2025, 9:13 AM5.toJsNumber() you get 5, when you pass 5 you get WasmStructObjectPiotr Krzemiński
10/02/2025, 9:14 AMRobert Jaros
10/02/2025, 9:15 AMCLOVIS
10/02/2025, 12:04 PMYou could create a second, private function with JsAny parameter and call it with some forced, unsafe casting.At this point, that second function could just be
dynamicCLOVIS
10/02/2025, 12:05 PMturansky
10/02/2025, 12:42 PM@file:JsQualifier("Number")
internal external actual fun isInteger(value: JsAny): Boolean
😉turansky
10/02/2025, 12:46 PMPiotr Krzemiński
10/03/2025, 7:09 AMfun isInteger(value: Number): Boolean {
return value is Byte || value is Short || value is Int || value is Long
}
demo