https://kotlinlang.org logo
#javascript
Title
# javascript
e

Edoardo Luppi

11/03/2023, 11:25 AM
I'm trying to add an external class to access
linkedom/xml/XMLDocument
, as per screenshot. What would be the correct way to do it?
a

Artem Kobzar

11/03/2023, 11:33 AM
I would add it as:
Copy code
// FILE: XMLDocument.kt
@file:JsModule("linkedom/xml/XMLDocument")
package linkedom.xml

external class XMLDocument
gratitude thank you 1
e

Edoardo Luppi

11/03/2023, 11:36 AM
> Package subpath './xml/XMLDocument' is not defined by "exports" Seems like this class wasn't meant to be accessible by users
a

Artem Kobzar

11/03/2023, 2:03 PM
You mean from the perspective of the
linkedom/xml/XMLDocument
library developers, or your users of the Kotlin code shouldn't have access to the class?
e

Edoardo Luppi

11/03/2023, 2:04 PM
Oh I meant from the linkedom devs perspective. It appears it's only used internally and not meant to be created or seen externally.
I wanted to create a new
XMLDocument
without the parsing stage. But I ended up doing it like this:
Copy code
val document = domParser.parseXmlFromString("<$rootTagName/>")
a

Artem Kobzar

11/03/2023, 2:22 PM
I see. In this case you still can use it like I mentioned above, but if the structure of project is changed or the class is removed you will need to rework. If you ask me, I would use only public API 😄
e

Edoardo Luppi

11/03/2023, 2:31 PM
Yup agree, I'll keep it simple. Off topic but just wanted to see if it's still on your radar: we plan to ship the npm packages to be used by JS/TS consumers. Not now but probably Q2 2024. Is documentation still planned to be added to generated d.ts files?
a

Artem Kobzar

11/03/2023, 3:00 PM
So, we already add
deprecated
TS-doc to declarations with the
Deprecated
annotation, but adding comments is much harder to do in the current compiler architecture. We are looking the way to do it, but it's not something that we could ship the nearest 2 quarters.
e

Edoardo Luppi

11/03/2023, 3:02 PM
Ok, that's good to know so I can adjust our plans, thanks!