js2dts
Generate dts for javascript
Install
npm i js2dts -g
or
yarn global add js2dts
Usage
Usage: j2d [options] <file>
Options:
-v, --version output the version number
-d, --dist [path] Create dts to giving path (default to the same dir as file)
-t, --terminal Output the result to terminal instead of writing file to disk
--no-prefix The generated code will has no prefix
--ignore-private Private properties are also being export
-h, --help output usage information
Example
$ j2d ./test.js
or
$ js2dts ./test.js
Example
source code
// function/index.jsmoduleexports = superName; /** * super function * * @param */ { return '123123';} moduleexports 123123;moduleexportstest2 = abc: 123;
output dts
// function/index.d.ts/** * super function * * @param */declare ;declare ;declare ;
More example: tests/fixtures/**/*.d.ts