TypeScript 's type definition file (*.d.ts files) generator tool from JavaScript files.
TypeScript's type definition file (*.d.ts files) generator tool from JavaScript files.
TypeScript's type definition file (
*.d.tsfiles) generator tool from JavaScript files. This tool is WIP (Work In Progress).
A Japanese document: TypeScript型定義ファイルのコツと生成ツール dtsmake
*.d.tsfile from a JavaScript file.
Node.js
npm i dtsmake -g
simple case:
dtsmake -s ./path/to/sourcefile.jsother 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
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-*.
gulp-header->
gulpHeader
-M "gulp-*"
-p node
-N
-e
-l "/path/to/node.d.ts"
output usage information
output the version number
[MUST] target javascript file path
outout d.ts file path. no need
.d.tsfile extension.
ex.
--dist /path/to/dist->
/path/to/dist.d.ts
module name
tern.js plugin.
ex.
-p "node,module,commonjs"
tern.js def files. DEFAULT:'ecma5'
see Tern.js's def json format and Tern.js's sample def files.
sample files for target js lib. help for ternjs type inference.
ex.
-x "./path/to/extrafile1.js,./path/to/extrafile2.js"
debug output mode
force output
voidto
any
export a namespace property same with a interface name
annotate interface's constructor type as return type instance
how to export objects that same name with JS Global Object; "remove" or "wrap" or "rename"; DEFAULT:"wrap"
//--globalObject "remove" // ※no output//--globalObject "wrap" declare namespace mylib{ interface Error{ //... } }
//--globalObject "rename" interface Mylib$Error{ //... }
nodejs module special replace
add export statement in a bottom of d.ts file
if --outExport true, select export style "es6" or "legacy"
//--exportStyle "legacy" declare module 'mylib'{ export = mylib; //legacy ts module export } //--exportStyle "es6" declare module 'mylib'{ export defalut mylib; //es6 style module export }
exporting module name.
ex. "EXAMPLE"; usage
import example = require("EXAMPLE");
add referrece path d.ts files.
ex.
--lib path/to/ex1.d.ts,path/to/ex2.d.ts
=>
/// ///
@param,
@return) duplication when it was already defined in the target JavaScript code.
-p node(Ternjs's Nodejs plugin) option is ON, dtsmake sometimes outputs nothing.
see TODO.md
MIT