Hi all, what is the best approach for integrating ...
# javascript
b
Hi all, what is the best approach for integrating https://github.com/visjs/vis-network into my kotlin/react project, it has https://github.com/visjs/vis-network/tree/master/types d.ts files inside here. Should I copy all these files and run Dukat on that and continue from that point?
t
Looks like manual convertion will be more effective in that case. Do you use IR?
b
No I do not, would it be useful in my case?
And what's the best way to start manual conversion?
t
With IR you can use Seskar plugin to describe NetworkEvent union for example
And what’s the best way to start manual conversion?
1. Create library package
vis.network
2. Copy TS typings 3. Create simple replacements
export interface
->
external interface
string
->
String
… 4. Add
@file:JsModule("vis-network")
5. Use
commonjs
for Kotlin/JS build
Dukat plan: 1. Run dukat 2. Fix enums -> unions 3. Remove redundant constructions 4. Fix lambda names (for TS types)
b
Sorry for being such a noob in Kotlin, but where should my
vis.network
library package be located? the TS typing also has multiple files, can I combine them into 1 file or should I create separate files for every TS typing file
t
1. Usual practice - separate subproject for library 2. Separate files preferred
You can find examples in
kotlin-wrappers
For example - react-table wrappers
b
Thanks for your help, before I start writing, do the dependencies matter from the library? Because I'm going to work with vis-network, which has the TS typings, but vis-network has dependencies of vis-data.
Would this be how I should continue?
image.png
t
do the dependencies matter from the library?
Yes, if there types used in your library public API
any
or
dynamic
means, that it can be more strict 🙂
Strict typings possible in Kotlin/JS
1
b
I need to use a dependency for the library public API, but that dependency is only written in .ts and doesn't have d.ts files. That would mean I need to derive my .kt file from the .ts files right? Which would make it require even more effort?
t
That would mean I need to derive my .kt file from the .ts files right?
You can check
npm
package in that case Usually typings generated during build and included inside
npm
package