I encountered the following error: ```TypeError: C...
# javascript
r
I encountered the following error:
Copy code
TypeError: Cannot read properties of undefined (reading 'plus_4zeyed$')
I have the declaration in common:
Copy code
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:
Copy code
@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:
Copy code
@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?
g
(There was a mangling issue in 1.6.20 on internal fields iirc, make sure to use 1.6.21 if it's not already the case.)
1
r
OK,Get it, thanks