dts-xdr is a library for generating TypeScript declarations file (.d.ts) for js-xdr auto-generated files.
This library uses jscodeshift to generate the definitions, follow the steps below to generate definitions.
git clone https://github.com/stellar/dts-xdr.git
cd dts-xdr
yarn installYou can use this library in two mode:
The first one is using inline replacement which is the default mode when you call jscodeshift. The following will replace the given file with the generated code:
npx jscodeshift -t src/transform.js sample/stellar-xdr_generated.js
After you run the command above, sample/stellar-xdr_generated.js will have the type definitions.
The second mode is specifying an output file, this mode won't change the source file. The following command will generate a new file called stellar-xdr_generated.d.ts with the TypeScript declarations:
OUT=stellar-xdr_generated.d.ts npx jscodeshift -t src/transform.js sample/stellar-xdr_generated.js