Ran
05/19/2022, 11:14 AMTypeError: Cannot read properties of undefined (reading 'plus_4zeyed$')
I have the declaration in common:
expect class BigDecimal(raw: String) {
fun add(bigDecimal: BigDecimal): BigDecimal
companion object {
val ONE: BigDecimal
val MAX: BigDecimal
val MIN: BigDecimal
}
}
internal val maxValue = ""
internal val max = BigDecimal(maxValue)
internal val minValue = ""
internal val min = BigDecimal(minValue)
In jsMain:
@JsModule("bignumber.js")
@JsNonModule
external class BigNumber(raw: String) {
fun plus(number: BigNumber): BigNumber
}
actual class BigDecimal actual constructor(raw: String) {
private val delegate: BigNumber = BigNumber(raw)
actual companion object {
actual val ONE: BigDecimal = one
actual val MAX: BigDecimal = max
actual val MIN: BigDecimal = min
}
actual fun add(bigDecimal: BigDecimal): BigDecimal {
return BigDecimal(delegate.plus(bigDecimal.delegate).toPlainString())
}
}
I have following unit test:
@Test
fun testOverflow() {
assertEquals(maxValue, (BigDecimal.MAX + BigDecimal.ONE).toPlainString())
}
I got the error I post when I run the unit test for js target. Is there anyone who can tell me what's wrong here?Grégory Lureau
05/19/2022, 12:24 PMRan
05/19/2022, 1:16 PM