TypeScript d.ts file generator from JavaScript files
npm install dtsmakedtsmake
====
TypeScript's type definition file (*.d.ts files) generator tool from JavaScript files.
  
*.d.ts files) generator tool from JavaScript files. This tool is WIP (Work In Progress).
.d.ts file from a JavaScript file.
npm i dtsmake -g
dtsmake -s ./path/to/sourcefile.js
`
other case:
`
dtsmake -s ./path/to/src/target.js --dist ./path/to/dist/mydefinition -n "mydefinition" -p node -e -S "legacy" -M "MyDefinition" -x "./path/to/extrafile1.js,./path/to/extrafile2.js" -N --def ./path/to/def/ecma6 -A -i -a -g
`
$3
* more usage examples -> /example/example.js
* generated TS definition files examples -> /example/dist/
$3
#### Generating Gulp.js plugin definition files
dtsmake -s /path/to/gulp/any/plugin.js -n "canalCasePluginName" -p node -e -M "gulp-*" -N -l "/path/to/node.d.ts"
* -n "canalCasePluginName"
gulp.js plugins has a name as gulp-.
* but, this is a invalid namespace name in TS.
* so, naming canal case.
* ex. gulp-header -> gulpHeader
* or valid namespace name.
-M "gulp-"
* no need to name canal case.
* -p node
* use nodejs plugin of tern server.
* -N
* set nodejs module option ON
* -e
* set export option ON
* -l "/path/to/node.d.ts"
* add referrece path to node.d.ts definition file
$3
#### -h, --help
output usage information
#### -v, --version
output the version number
#### -s, --src
__[MUST]__ target javascript file path
#### --dist [value]
outout d.ts file path. no need .d.ts file extension.
ex. --dist /path/to/dist -> /path/to/dist.d.ts
#### -n, --n [value]
module name
#### -p, --plugin
tern.js plugin.
* see tern.js server plugin
* currently support plugins
ex. -p "node,module,commonjs"
#### -d, --def
tern.js def files. DEFAULT:'ecma5'
see Tern.js's def json format and Tern.js's sample def files.
#### -x, --extrafiles
sample files for target js lib. help for ternjs type inference.
ex. -x "./path/to/extrafile1.js,./path/to/extrafile2.js"
#### -D, --debug
debug output mode
#### -A, --voidAsAny
force output void to any
#### -i, --interfaceSameNameVar
export a namespace property same with a interface name
#### -a, --annotateTypeInstance
annotate interface's constructor type as return type instance
#### -g, --globalObject [value]
how to export objects that same name with JS Global Object; "remove" or "wrap" or "rename"; DEFAULT:"wrap"
`javascript
//--globalObject "remove"
// ※no output
//--globalObject "wrap"
declare namespace mylib{
interface Error{
//...
}
}
//--globalObject "rename"
interface Mylib$Error{
//...
}
`
#### -N, --NodeJSModule
nodejs module special replace
#### -e, --export
add export statement in a bottom of d.ts file
#### -S, --exportStyle [value]
if --outExport true, select export style "es6" or "legacy"
`javascript
//--exportStyle "legacy"
declare module 'mylib'{
export = mylib; //legacy ts module export
}
//--exportStyle "es6"
declare module 'mylib'{
export defalut mylib; //es6 style module export
}
`
#### -M, --exportModuleName [value]
exporting module name.
ex. "EXAMPLE"; usage import example = require("EXAMPLE");
#### -l, --lib
add referrece path d.ts files.
ex. --lib path/to/ex1.d.ts,path/to/ex2.d.ts
=>
`javascript
///
///
`
Known Issues
1. JSDoc tag (@param, @return) duplication when it was already defined in the target JavaScript code.
2. When -p node` (Ternjs's Nodejs plugin) option is ON, dtsmake sometimes outputs nothing.