Is there an idiom for `collection.map { it.unsafeC...
# javascript
p
Is there an idiom for
collection.map { it.unsafeCast<SomeExternalInterface> }
which is undestood by the compiler and transpiled efficiently? It is something that comes up from time to time when interacting with js libs and last time I checked the resulting code was a for loop instead of a no-op
t
Copy code
inline fun <T, R: T> List<T>.unsafeMap(): List<R> {
    unsafeCast<List<R>>()
}