{"id":13392527,"url":"https://github.com/ConquestArrow/dtsmake","last_synced_at":"2025-03-13T18:31:50.915Z","repository":{"id":57216860,"uuid":"41555057","full_name":"ConquestArrow/dtsmake","owner":"ConquestArrow","description":"TypeScript 's type definition file (*.d.ts files) generator tool from JavaScript files. ","archived":true,"fork":false,"pushed_at":"2017-03-02T14:39:21.000Z","size":168,"stargazers_count":250,"open_issues_count":11,"forks_count":23,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-05-11T11:01:44.691Z","etag":null,"topics":["generator","javascript","ternjs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ConquestArrow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-28T15:34:08.000Z","updated_at":"2024-02-04T10:15:48.000Z","dependencies_parsed_at":"2022-08-28T21:01:42.374Z","dependency_job_id":null,"html_url":"https://github.com/ConquestArrow/dtsmake","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ConquestArrow%2Fdtsmake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ConquestArrow%2Fdtsmake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ConquestArrow%2Fdtsmake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ConquestArrow%2Fdtsmake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ConquestArrow","download_url":"https://codeload.github.com/ConquestArrow/dtsmake/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243459109,"owners_count":20294340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generator","javascript","ternjs","typescript"],"created_at":"2024-07-30T17:00:26.623Z","updated_at":"2025-03-13T18:31:50.589Z","avatar_url":"https://github.com/ConquestArrow.png","language":"TypeScript","readme":"dtsmake \n====\n\n[TypeScript](http://www.typescriptlang.org/)'s type definition file (*.d.ts files) generator tool from JavaScript files. \n\n[![Build Status](https://travis-ci.org/ConquestArrow/dtsmake.svg?branch=master)](https://travis-ci.org/ConquestArrow/dtsmake) [![NPM version](https://badge.fury.io/js/dtsmake.svg)](http://badge.fury.io/js/dtsmake) [![Dependency status](https://david-dm.org/ConquestArrow/dtsmake.svg)](https://david-dm.org/ConquestArrow/dtsmake#info=dependencies\u0026view=table) \n\n## Description\n\n[TypeScript](http://www.typescriptlang.org/)'s type definition file (`*.d.ts` files) generator tool from JavaScript files. This tool is **WIP** (Work In Progress).\n\nA Japanese document: [TypeScript型定義ファイルのコツと生成ツール dtsmake](http://qiita.com/ConquestArrow/items/450f961c3d54bc932cf3)\n\n### Features\n\n * Generating a `*.d.ts` file from a JavaScript file.\n * Type inference powered by [TernJS](http://ternjs.net/). (Need some sample JS files.)\n * Auto annotation JSDoc style comments.\n * Original JSDoc comment in base JS code output.\n * Header template output.\n\n## VS. \n\n* [dtsgenerator](https://github.com/horiuchi/dtsgenerator) - d.ts file generator tool, for only JSON Schema files.\n* [js2tsd](https://github.com/mhelvens/js2tsd) - d.ts file generator tool, no type inferrence.\n* [JS2TSD](http://nekok.com/2014/05/javascript-to-typescript-type-definitions-d-ts-auto-converter/) d.ts file generator GUI tool app. Not CLI.\n\n## Requirement\n\nNode.js\n\n## Install\n\n`npm i dtsmake -g`\n\n## Usage\n\nsimple case:\n```\ndtsmake -s ./path/to/sourcefile.js\n```\nother case:\n```\ndtsmake -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\n```\n\n### Example\n\n\n * more usage examples -\u003e [/example/example.js](./example/example.js)\n * generated TS definition files examples -\u003e [/example/dist/](./example/dist/)\n\n### Best Practice\n\n#### Generating Gulp.js plugin definition files\n\n`dtsmake -s /path/to/gulp/any/plugin.js -n \"canalCasePluginName\" -p node -e -M \"gulp-*\" -N -l \"/path/to/node.d.ts\"`\n\n * `-n \"canalCasePluginName\"`\n  * gulp.js plugins has a name as `gulp-*`.\n  * but, this is a invalid namespace name in TS.\n  * so, naming canal case.\n   * ex. `gulp-header` -\u003e `gulpHeader`\n   * or valid namespace name.\n * `-M \"gulp-*\"`\n  * no need to name canal case. \n * `-p node`\n  * use nodejs plugin of tern server. \n * `-N`\n  * set nodejs module option ON\n * `-e`\n  * set export option ON\n * `-l \"/path/to/node.d.ts\"`\n  * add referrece path to node.d.ts definition file\n  \n\n### Options\n\n#### -h, --help                    \n output usage information\n#### -v, --version                 \n output the version number\n#### -s, --src `\u003cpath\u003e`              \n __[MUST]__ target javascript file path\n#### --dist [value]                \n outout d.ts file path. no need `.d.ts` file extension.\n\nex. `--dist /path/to/dist` -\u003e `/path/to/dist.d.ts`\n\n#### -n, --n [value]               \n module name\n#### -p, --plugin `\u003cnames\u003e`          \n tern.js plugin.\n \n  * see [tern.js server plugin](http://ternjs.net/doc/manual.html#plugins)\n  * [currently support plugins](https://github.com/marijnh/tern/tree/0.14.0/plugin)\n\nex. `-p \"node,module,commonjs\"`\n\n#### -d, --def `\u003cpaths\u003e`             \n tern.js def files. DEFAULT:'ecma5'\n \n see [Tern.js's def json format](http://ternjs.net/doc/manual.html#typedef) and [Tern.js's sample def files](https://github.com/marijnh/tern/tree/master/defs).\n#### -x, --extrafiles `\u003cpaths\u003e`      \n sample files for target js lib. help for ternjs type inference.\n \n ex. `-x \"./path/to/extrafile1.js,./path/to/extrafile2.js\"`\n#### -D, --debug                   \n debug output mode\n#### -A, --voidAsAny               \n force output `void` to `any`\n#### -i, --interfaceSameNameVar    \n export a namespace property same with a interface name\n#### -a, --annotateTypeInstance    \n annotate interface's constructor type as return type instance\n#### -g, --globalObject [value]            \n how to export objects that same name with JS Global Object; \"remove\" or \"wrap\" or \"rename\"; DEFAULT:\"wrap\" \n\n```javascript\n//--globalObject \"remove\"\n// ※no output\n\n//--globalObject \"wrap\"\ndeclare namespace mylib{\n    interface Error{\n        //...\n    }\n}\n\n//--globalObject \"rename\"\ninterface Mylib$Error{\n    //...\n}\n```\n\n\n#### -N, --NodeJSModule            \n nodejs module special replace\n#### -e, --export                  \n add export statement in a bottom of d.ts file\n#### -S, --exportStyle [value]     \n if --outExport true, select export style \"es6\" or \"legacy\"\n\n```javascript\n//--exportStyle \"legacy\"\ndeclare module 'mylib'{\n    export = mylib;    //legacy ts module export\n}\n//--exportStyle \"es6\"\ndeclare module 'mylib'{\n    export defalut mylib;    //es6 style module export \n}\n```\n \n#### -M, --exportModuleName [value]\n\nexporting module name. \n \nex. \"EXAMPLE\"; usage `import example = require(\"EXAMPLE\");`\n\n#### -l, --lib `\u003cpaths\u003e`\n\nadd referrece path d.ts files. \n\nex. `--lib path/to/ex1.d.ts,path/to/ex2.d.ts`\n\n=\u003e\n\n```javascript\n/// \u003creference path=\"path/to/ex1.d.ts\" /\u003e\n/// \u003creference path=\"path/to/ex2.d.ts\" /\u003e\n```\n\n\n## Known Issues\n\n 1. JSDoc tag (`@param`, `@return`) duplication when it was already defined in the target  JavaScript code.\n 2. When `-p node` (Ternjs's Nodejs plugin) option is ON, dtsmake sometimes outputs nothing.\n 3. Only support Tern.js server plugins in [here](https://github.com/marijnh/tern/tree/0.14.0/plugin). \n\n## TODOs\n\n * Tern.js's server plugin without default support.\n  * tern/condense cmd cannot load 3rd party plugins (ex. [tern-gulp](https://github.com/angelozerr/tern-gulp) ), so, replace or patches it.\n\nsee [TODO.md](./TODO.md)\n\n## Licence\n\nMIT\n\n## Author\n\nConquestArrow\n[Github](https://github.com/ConquestArrow/) | [Qiita](http://qiita.com/ConquestArrow)\n\n","funding_links":[],"categories":["TypeScript","Table of Contents"],"sub_categories":["Migrating JavaScript"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FConquestArrow%2Fdtsmake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FConquestArrow%2Fdtsmake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FConquestArrow%2Fdtsmake/lists"}