Convert Javascript to Haxe using refactor

Hi,
I want to convert a javascript class to Haxe. (Which is Nakama Backend JS Client, nakama-js.umd.js)
in order to do that, I’ve tried to use refactor tool. which is a haxelib tool
after installing refactor, I’ve executed the following command:

haxelib run refactor js_to_haxe nakama-js.umd.js

but i get the following error:

Called from ? line 1
Called from Main.hx line 72
Called from hant/Process.hx line 196
Called from hant/Process.hx line 99
Called from a C function
Called from hant/Process.hx line 174
Called from hant/Process.hx line 173
Called from a C function
Called from C:\MyProg\_tools\motion-twin\haxe\std/neko/Lib.hx line 42
Uncaught exception - load.c(237) : Failed to load library : hant.ndll
Stack trace:
        Called from a C function
        Called from hant/Process.hx line 10
        Called from a C function
        Called from hant/Process.hx line 10
        Called from hant/Process.hx line 174
        Called from a C function
        Called from hant/Process.hx line 99
        Called from hant/Process.hx line 196
        Called from Main.hx line 72
        Called from ? line 1

I also tried installing hant lib. nothing changed.

1 Like

This looks to be something going wrong with the refactor tool itself (you may need to use an older version of haxe to make it work) @yar3333 is the author and might know more

In any case direct working translation of ts to haxe is not really possible at present, so lots of manual work will still be required

It’s possible to convert the type interface to haxe which may save some time, make a new directory and run this:

npm i @heroiclabs/nakama-js dts2hx
npx dts2hx @heroiclabs/nakama-js

This will generate haxe externs (types, classes and function signatures) which you could use as a starting point – you’ll still need to fill in the function bodies by hand