I keep running into this issue - ```TypeError: tm...
# javascript
g
I keep running into this issue -
Copy code
TypeError: tmp$.iterator is not a function
while iterating a nullable list type. (Kotlin/js - 1.3.61). Also, this is an MPP project using coroutines. This error occurs inside a coroutine Ex -
Copy code
val marked: List<User> = dto.accounts?.map { User(it) } ?: listOf()

// where accounts is of type List<T>?
Webpack error message -
Copy code
Could not load content for webpack:///generated/_Collections.kt?f709 : HTTP status code: 404
Maybe this is the main issue.
If I switch to Array<T>? it works fine.
r
Is this data (dto.accounts) by any chance coming from json?
g
Yep, and it is serialized using JSON.parse
r
When you parse from json the prototype is not set on the javascript objects and methods don't work.
When you use kotlinx.serialization you don't have this problem. Or keep the dto's simple and use arrays i.o. lists.
Btw, extension functions will still work, so that might help.
g
Oh okay, thanks. The problem I had with kotlinx.serialization was with generics. I want to serialize SomeCustomClass<T>, but right now it only supports List<T> and some other basic ones. link - https://kotlinlang.slack.com/archives/C7A1U5PTM/p1578059023023800
r
I responded to the question about serializing generics, which is possible.