Question for folks using the new JS IR: Does `@JsE...
# javascript
a
Question for folks using the new JS IR: Does
@JsExport
also prevent name mangling? Or do you need to use both
@JsExport
and
@JsName
for that?
👌 1
t
Yes, it does
a
Nice! It seems like
@JsExport
is responsible for a few different things, but the actual behavior varies depending on the compiler: • exporting TS types (new IR only) • preventing DCE from removing (new IR only?) • preventing name mangling (new IR and legacy) Is this accurate?
t
All 3 things works in IR only
Names are non-mangled in legacy by default, but it’s not a contract 🙂
👍 1
Non-mangled names - contract of export feature
a
There is a gotcha, where a non-JsExport'ed implementation of a JsExport'ed interface is unusable, because the members of the impl class are all prefixed with underscore. No amount of JsName will help with this.
t
Looks like external interfaces can solve this problem
a
Not sure what you mean by that? Do you have a link to some docs I could look at?
do you mean the external declarations used on the kotlin side when you wan to call JS code?
t
If JsName doesn't work for mangling block, than you can create external interface and implement it
External interface properties/methods will be non-mangled
a
Yes, but this doesn't work unless the class that implements the interface is also JsExported
because the member names of the class are prefixed with underscore, while those of the interface are not
if you JsExport a class, it does not have this problem, but an interface does
t
Is there example?
a
Let me spend a little time to put something together - the code I currently have is closed.