All Projects → ConquestArrow → Dtsmake

ConquestArrow / Dtsmake

Licence: mit
TypeScript 's type definition file (*.d.ts files) generator tool from JavaScript files.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Labels

Projects that are alternatives of or similar to Dtsmake

Gpt Scrolls
A collaborative collection of open-source safe GPT-3 prompts that work well
Stars: ✭ 195 (-15.58%)
Mutual labels:  generator
Vue Generate Component
Vue js component generator
Stars: ✭ 206 (-10.82%)
Mutual labels:  generator
Mockery
A mock code autogenerator for Golang
Stars: ✭ 3,138 (+1258.44%)
Mutual labels:  generator
Laravel Tournaments
Laravel Package that allows you to generate customizable tournaments trees.
Stars: ✭ 196 (-15.15%)
Mutual labels:  generator
Php Ulid
A PHP port of alizain/ulid with some minor improvements.
Stars: ✭ 203 (-12.12%)
Mutual labels:  generator
Pollinate
Template your base files and generate new projects from Git(Hub).
Stars: ✭ 213 (-7.79%)
Mutual labels:  generator
Pydbgen
Random dataframe and database table generator
Stars: ✭ 191 (-17.32%)
Mutual labels:  generator
Github Profilinator
🚀 This tool contains mini GUI components that you can hook together to automatically generate markdown code for a perfect readme.
Stars: ✭ 225 (-2.6%)
Mutual labels:  generator
Regressor
Generate specs for your rails application the easy way. Regressor generates model and controller specs based on validations, associations, enums, database, routes, callbacks. Use regressor to capture your rails application behaviour.
Stars: ✭ 204 (-11.69%)
Mutual labels:  generator
Stator
Stator, your go-to template for the perfect stack. 😍🙏
Stars: ✭ 217 (-6.06%)
Mutual labels:  generator
Apigcc
一个非侵入的api编译、收集、Rest文档生成工具。工具通过分析代码和注释,获取文档信息,生成RestDoc文档。
Stars: ✭ 198 (-14.29%)
Mutual labels:  generator
Fantasy Map Generator
Web application generating interactive and highly customizable maps
Stars: ✭ 2,802 (+1112.99%)
Mutual labels:  generator
Generators
API Generator - instantly generate REST and GraphQL APIs (openapi (OAS) 3.0.0)
Stars: ✭ 213 (-7.79%)
Mutual labels:  generator
Hermes
Golang package that generates clean, responsive HTML e-mails for sending transactional mail
Stars: ✭ 2,379 (+929.87%)
Mutual labels:  generator
Toa
A pithy and powerful web framework.
Stars: ✭ 220 (-4.76%)
Mutual labels:  generator
Sdk
Library for using Grafana' structures in Go programs and client for Grafana REST API.
Stars: ✭ 193 (-16.45%)
Mutual labels:  generator
Generator Web Extension
Advanced WebExtension generator that creates everything you need to get started with cross-browser web-extension development.
Stars: ✭ 212 (-8.23%)
Mutual labels:  generator
Laravel Craftsman
Laravel Craftsman CLI for easily crafting Laravel assets for any project (artisan make on steroids)
Stars: ✭ 227 (-1.73%)
Mutual labels:  generator
Readme
Automatically generate a beautiful best-practice README file based on the contents of your repository
Stars: ✭ 223 (-3.46%)
Mutual labels:  generator
Co Mocha
Enable support for generators in Mocha tests
Stars: ✭ 216 (-6.49%)
Mutual labels:  generator

dtsmake

TypeScript's type definition file (*.d.ts files) generator tool from JavaScript files.

Build Status NPM version Dependency status

Description

TypeScript's type definition file (*.d.ts files) generator tool from JavaScript files. This tool is WIP (Work In Progress).

A Japanese document: TypeScript型定義ファイルのコツと生成ツール dtsmake

Features

  • Generating a *.d.ts file from a JavaScript file.
  • Type inference powered by TernJS. (Need some sample JS files.)
  • Auto annotation JSDoc style comments.
  • Original JSDoc comment in base JS code output.
  • Header template output.

VS.

  • dtsgenerator - d.ts file generator tool, for only JSON Schema files.
  • js2tsd - d.ts file generator tool, no type inferrence.
  • JS2TSD d.ts file generator GUI tool app. Not CLI.

Requirement

Node.js

Install

npm i dtsmake -g

Usage

simple case:

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

Example

Best Practice

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

Options

-h, --help

output usage information

-v, --version

output the version number

-s, --src <path>

[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 <names>

tern.js plugin.

ex. -p "node,module,commonjs"

-d, --def <paths>

tern.js def files. DEFAULT:'ecma5'

see Tern.js's def json format and Tern.js's sample def files.

-x, --extrafiles <paths>

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"

//--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"

//--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 <paths>

add referrece path d.ts files.

ex. --lib path/to/ex1.d.ts,path/to/ex2.d.ts

=>

/// <reference path="path/to/ex1.d.ts" />
/// <reference path="path/to/ex2.d.ts" />

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.
  3. Only support Tern.js server plugins in here.

TODOs

  • Tern.js's server plugin without default support.
  • tern/condense cmd cannot load 3rd party plugins (ex. tern-gulp ), so, replace or patches it.

see TODO.md

Licence

MIT

Author

ConquestArrow Github | Qiita

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].