At the end I used this workaround. It's ugly but works, let me know if there is a better way, I would be thankful.
Copy code
val lastModified = (js("file.lastModified.toString()") as String).toLongOrNull()
if (lastModified != null) Instant.fromEpochMilliseconds(lastModified.toLong())
m
Mike Dawson
09/12/2023, 8:15 AM
I think the file.lastModified property is a Javascript number type :
Integers can only be represented without loss of precision in the range -2^53 + 1 to 2^53 - 1, inclusive (obtainable via Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER), because the mantissa can only hold 53 bits (including the leading 1).
As per: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number
Mike Dawson
09/12/2023, 8:16 AM
In Kotlin/JS Long is handled using a Wrapper class, whereas other primitives use the JS native Number