Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dsherret/dts-minify
Minifier for TypeScript declaration files (.d.ts)
https://github.com/dsherret/dts-minify
Last synced: 2 months ago
JSON representation
Minifier for TypeScript declaration files (.d.ts)
- Host: GitHub
- URL: https://github.com/dsherret/dts-minify
- Owner: dsherret
- License: mit
- Created: 2019-11-17T04:42:31.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-03-30T19:00:46.000Z (9 months ago)
- Last Synced: 2024-10-05T17:48:19.090Z (3 months ago)
- Language: TypeScript
- Size: 85 KB
- Stars: 24
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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:
```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:
```ts
declare class MyClass{/**
* Some description.
*/doSomething(value:number):number;}
```