Kotlin JS InterOp External doesn’t work I added b...
# javascript
r
Kotlin JS InterOp External doesn’t work I added big-number dependency for jsMain:
Copy code
val jsMain by getting {
    dependencies {
        implementation(npm("big-number", "2.0.0", true))
    }
}
In jsMain, I use external to tell compiler that the BigNumber class is implemented by js:
Copy code
external class BigNumber(raw: dynamic) {
    fun plus(number: BigNumber): BigNumber
}
The I use BigNumber in kotlin code, but i get this error:
ReferenceError: BigNumber is not defined
Is there anyone can give me a help, thanks so much.
g
Do you have the same packageName/namespace in JS and Kotlin?
r
No, I defined the external class under package com.calculation.tools
b
external declarations depend on how JS/TS code is exported.
r
Ok, I’ll read the doc you provided throughly, thanks so much
Thanks, I solved my problem.
b
Glad to hear that. Mind posting back here what was the root cause and the solution in case somebody else encounters it in the future?