After updating Kotlin from 2.1.10 to 2.1.20 my cod...
# javascript
r
After updating Kotlin from 2.1.10 to 2.1.20 my code throws
KotlinNothingValueException
. Anyone experienced something like that? More in thread.
This function:
Copy code
fun toPlainObj(data: T): dynamic {
        return if (jsonHelper == null || serializer == null) {
            throw IllegalStateException("The data class can't be serialized. Please provide a serializer when creating the Tabulator instance.")
        } else {
            @Suppress("UnsafeCastFromDynamic")
            JSON.parse(jsonHelper!!.encodeToString(serializer, data))
        }
    }
in 2.1.20 is translated to this code:
Copy code
function (data) {
    var tmp;
    if (this.get_jsonHelper_i4zo3l_k$() == null || this.serializer_1 == null) {
      throw IllegalStateException_init_$Create$("The data class can't be serialized. Please provide a serializer when creating the Tabulator instance.");
    } else {
      JSON.parse(ensureNotNull(this.get_jsonHelper_i4zo3l_k$()).encodeToString_k0apqx_k$(this.serializer_1, data));
      throwKotlinNothingValueException();
    }
    return tmp;
  };
t
Will it work if you won't use
dynamic
?
e
it seems that the compiler is now inferring
JSON.parse<Nothing>()
. it works if you explicitly write
Copy code
JSON.parse<dynamic>()
or
Copy code
JSON.parse<Any?>().asDynamic()
as for why that is, I don't know
r
This fixes the problem as well:
Copy code
fun toPlainObj(data: T): dynamic {
        if (jsonHelper == null || serializer == null) {
            throw IllegalStateException("The data class can't be serialized. Please provide a serializer when creating the Tabulator instance.")
        }
        @Suppress("UnsafeCastFromDynamic")
        return JSON.parse(jsonHelper!!.encodeToString(serializer, data))
    }
It's a bug, isn't it?
e
looks like a bug, I would agree
t
Tax on
dynamic
usage 😉
e
Damn, already fixed it seems!