Hello, In Kotlin/WasmJs, I've created a simple sma...
# multiplatform
r
Hello, In Kotlin/WasmJs, I've created a simple small function js wrapper:
Copy code
fun jsLocalStorageGetItem(key: String): String =
    js("window.localStorage.getItem(key)")
If the key exist, no problem. If the key doesn't exist I have a
NullPointerException
on the browser console. I've try to add a
String?
as a return type
Copy code
fun jsLocalStorageGetItem(key: String): String? =
    js("window.localStorage.getItem(key)")
But the compiler refuse this solution. Maybe I can get away with a try/catch (didn't try yet) but it seem odd to me we can't handle null value from calling js function...
image.png
r
Why the compiler refuses nullable return value for you? It works for me.
r
You are totally right. Thx. it simplified my code a lot