paulbellamy / dts-xdr

A library for generating TypeScript declarations (.d.ts) for js-xdr auto-generated files.

Home Page:https://github.com/stellar/dts-xdr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dts-xdr

Stellar

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.

Setup

git clone https://github.com/stellar/dts-xdr.git
cd dts-xdr
yarn install

Usage

You can use this library in two mode:

Source replacement

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.

Output mode

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

About

A library for generating TypeScript declarations (.d.ts) for js-xdr auto-generated files.

https://github.com/stellar/dts-xdr

License:Apache License 2.0


Languages

Language:JavaScript 100.0%