I have a problem and am not entirely sure what my ...
# react
w
I have a problem and am not entirely sure what my options are to solve it. I have a Kotlin/JS react project and am trying to use a library that defines a particular component. This library has an @types/lib type declaration package, but dukat fails to generate the externals due to a StackOverflowError. Downloading the index.d.ts and running dukat via the cli doesnt give this error, but it doesnt understand how to handle the react bindings and generates externals with wrong type names. Defining the definitions myself is very difficult as it is a very big library. (index.d.ts is roughly 5000 lines long) What I think I want is some way to make dukat work, or have some js/ts source code that acts as a bridge between the kotlin and external js code, where I can define a small type definition only for my purposes What options do I have to tackle this problem?
s
Dukat is garbage. It works in only the simplest of use cases. In the best cases that have worked for me, I've had to copy and paste the generated externals and then modify them so they compile. Hopefully now that the IR compiler is stable, they will move a resource back to dukat. If you are getting a stack overflow, that means that nothing was generated in your build directory?
Your best bet is probably going to be to define your own externals. If it's a component, you probably don't need to define externals for all 5k lines. You can probably get by with less than a hundred.
t
@Wietlol Which library wrappers do you need?
w
when I get the StackOverflowError, it did create something in the build directory, but not in the build/externals directory for the library that caused the error weirdly, when running the gradle dukat generateExternals again, it acts as a no-op
I suppose trimming the index.d.ts file for the specific stuff I need is probably my best bet atm
s
I would only use dukat as the start of generating externals. It sounds like you can't in this case
I would just write your own externals
What library are you trying to get external declarations for?
w
the libraries that work are very basic ones like jwt-decode while the ones that dont work are often react related like react-syntax-highlighter