# autodts

> Autodts generates d.ts files for publishing TypeScript projects on npm.

Latest version **0.0.6** (published 2015-11-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install autodts
pnpm add autodts
yarn add autodts
bun add autodts
```

Provides the command `autodts`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2015-11-09 |
| First published | 2015-08-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Juha Järvi |
| Maintainers | jjrv |

## Links

- npm: https://www.npmjs.com/package/autodts
- Repository: https://github.com/charto/autodts
- Issues: https://github.com/charto/autodts/issues
- npm.io page: https://npm.io/package/autodts

## Dependencies (3)

- [mkdirp](https://npm.io/package/mkdirp.md) ~0.5.1
- [minimist](https://npm.io/package/minimist.md) ~1.2.0
- [@lib/autolink](https://npm.io/package/@lib/autolink.md) 0.0.2

## Recent versions

- 0.0.6 (latest) — 2015-11-09
- 0.0.5 — 2015-10-02
- 0.0.4 — 2015-08-17
- 0.0.3 — 2015-08-11
- 0.0.2 — 2015-08-11
- 0.0.1 — 2015-08-03

## README

autodts
=======

[![npm version](https://img.shields.io/npm/v/autodts.svg)](https://www.npmjs.com/package/autodts) [![dependency status](https://david-dm.org/charto/autodts.svg)](https://david-dm.org/charto/autodts)

`autodts` generates `.d.ts` files for publishing TypeScript projects on npm.

Usage
-----

It's best to run `autodts` from the `package.json` file of a Node.js module. Here's an example:

```json
{
  "name": "example",
  "version": "0.0.1",
  "description": "Example of a TypeScript-based package",
  "scripts": {
    "preinstall": "npm install autodts",
    "postinstall": "autodts link",
    "prepublish": "tsc && autodts generate"
  },
  "typescript": {
    "definition": "index.d.ts"
  },
  "dependencies": {
    "autodts": "~0.0.6",
    "@lib/dependency-example": "0.0.3"
  },
  "devDependencies": {
    "@lib/autodts-generator": "~0.0.1",
    "typescript": "~1.5.3"
  }
}
```

The `preinstall` command is needed to work around [npm issue #5001](https://github.com/npm/npm/issues/5001).

`autodts link` checks all packages listed in `dependencies`. If their `package.json` file contains a `typescript` section with a `definition` setting, a reference is added to the output file `typings/auto.d.ts`, for example:

```typescript
// Automatically generated file. Edits will be lost.
/// <reference path="../node_modules/@lib/dependency-example/index.d.ts" />
```

This allows pulling the type information of all required modules into a TypeScript source file with a single `/// <reference path = "typings/auto.d.ts" />` statement.

An entire tree of npm packages written in TypeScript can be installed with correct references to typings if packages referencing types from others add the above `preinstall` and `postinstall` sections in their `package.json`.

It's possible to change the output file path using the `--out` parameter, for example: `autodts link --out typings/tsd.d.ts`.

`autodts generate` calls [autodts-generator](https://www.npmjs.com/package/@lib/autodts-generator) to produce a single `.d.ts` file with all type information in the package. It will be automatically written to the path defined in the `definition` setting in the `typescript` section of your `package.json` file. Using it requires a particular package structure, otherwise it's better to use [dts-generator](https://www.npmjs.com/package/dts-generator) directly.

To use the `generate` command, you should add `@lib/autodts-generator` to your `devDependencies`. `autodts` doesn't automatically require it, because it pulls the entire TypeScript compiler and is not needed for the `link` command.

`autodts link` is meant for the common case of installing TypeScript-based npm packages, `autodts generate` for the rarer event of publishing them.

License
=======

[The MIT License](https://raw.githubusercontent.com/charto/autodts/master/LICENSE)
Copyright (c) 2015 BusFaster Ltd

---
_Source: https://npm.io/package/autodts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
