# dts-minify

> Minifier for TypeScript declaration files (.d.ts).

Latest version **0.3.3** (published 2024-03-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install dts-minify
pnpm add dts-minify
yarn add dts-minify
bun add dts-minify
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.3 |
| Published | 2024-03-30 |
| First published | 2019-11-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 42.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | David Sherret |
| Maintainers | dsherret |

## Links

- npm: https://www.npmjs.com/package/dts-minify
- Repository: https://github.com/dsherret/dts_minify
- Homepage: https://github.com/dsherret/dts_minify#readme
- Issues: https://github.com/dsherret/dts_minify/issues
- npm.io page: https://npm.io/package/dts-minify

## Recent versions

- 0.3.3 (latest) — 2024-03-30
- 0.3.2 — 2023-01-05
- 0.3.1 — 2022-12-30
- 0.3.0 — 2021-11-13
- 0.2.3 — 2021-01-08
- 0.2.2 — 2021-01-08
- 0.2.1 — 2021-01-08
- 0.2.0 — 2019-11-17
- 0.1.0 — 2019-11-17

## README

# dts-minify

[![JSR](https://jsr.io/badges/@david/dts-minify)](https://jsr.io/@david/dts-minify)
[![npm version](https://badge.fury.io/js/dts-minify.svg)](https://badge.fury.io/js/dts-minify)
[![CI](https://github.com/dsherret/dts-minify/workflows/CI/badge.svg)](https://github.com/dsherret/dts-minify/actions?query=workflow%3ACI)

Minifies TypeScript declaration files (`.d.ts` files).

Strips:

- Non-essential whitespace and newlines.
- Comments, but keeps triple-slash directives.

## Use Case

This library is useful for minifying declaration files that won't be read by
humans.

## Setup

Deno:

```sh
deno add @david/dts-minify
```

Node:

```sh
npm install dts-minify
```

## Example

```ts
import { createMinifier } from "@david/dts-minify"; // dts-minify on npm
import * as ts from "typescript";

// setup (provide a TS Compiler API object)
const minifier = createMinifier(ts);

// minify
const inputText = `declare class MyClass {
    /**
     * Some description.
     */
    doSomething(value: number): number;
}`;
const minifiedText = minifier.minify(inputText);

console.log(minifiedText);
```

Outputs:

<!-- deno-fmt-ignore -->

```ts
declare class MyClass{doSomething(value:number):number;}
```

### Options

#### `keepJsDocs`

When true, it won't remove the JS docs.

```ts
const minifiedText = minifier.minify(inputText, {
  keepJsDocs: true, // false by default
});
```

Outputs:

<!-- deno-fmt-ignore -->

```ts
declare class MyClass{/**
 * Some description.
 */doSomething(value:number):number;}
```

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