does anyone know if "internal" functions will work...
# javascript
b
does anyone know if "internal" functions will work correctly with the Typescripting work coming in next release? We ran into an issue where our functions defined as internal couldn't be JS unit tested, because they're not emitted at all by the JS output
g
on the previous thread, this was shared as the eap for the next release. https://discuss.kotlinlang.org/t/kotlin-1-3-70-early-access-preview/15876
s
In current release
internal
functions are exprted to JS in order to be tested from Kotlin/JS test module. They have specially mangled names and we don't recommend using them from JS manually. In next release
intenal
functions would not be exported to JavaScript at all. You would still be able to use them from K/JS test module. I would recommend to either: • Write unit tests in Kotlin • Make them
public
and use them in JS unit tests
b
when you say they won't be exported at all... how will that work with cross-platform? If i write something with an internal function that works on ios/android, will it break when it attempts to call the internal function?
s
Just like in Kotlin/JVM and Kotlin/Native,
internal
declarations would be visible and fully functional within a single Kotlin module, and normally, not visible outside. However, test Kotlin modules use a special compiler option to bypass this restriction and use internals from main module. This would continue to work just fine in new release. What would not work is calling internals defined in Kotlin/JS from plain JavaScript code.
If i write something with an internal function that works on ios/android, will it break when it attempts to call the internal function?
No, if you call internal function from Kotlin code it will work the same on all platforms.
b
gotcha. We seem to be running into an issue where sometimes the namespace declaration in the JS file produced in the build/js/packages/<library> file isn't written out when the method is declared as internal. It appear to be intermittent though, because the same build rebuilt will contain it. I'm trying to see if I can get a minimum repro
s
Ouch. Having a repro would be awesome!