# extract-types

> extract types from js jsdoc ts json

Latest version **1.1.0** (published 2025-12-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install extract-types
pnpm add extract-types
yarn add extract-types
bun add extract-types
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

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

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2025-12-18 |
| First published | 2024-06-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | yuanliwei |
| Maintainers | yuanliwei |
| Keywords | extract, d.ts, jsdoc, types |

## Links

- npm: https://www.npmjs.com/package/extract-types
- Repository: https://github.com/yuanliwei/extract-types
- Homepage: https://github.com/yuanliwei/extract-types#readme
- Issues: https://github.com/yuanliwei/extract-types/issues
- npm.io page: https://npm.io/package/extract-types

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2025-12-18
- 1.0.1 — 2024-06-22
- 1.0.0 — 2024-06-22

## README

# extract-types

## 项目简介

`extract-types` 是一个工具，用于从 JavaScript、JSDoc、TypeScript 和 JSON 文件中提取类型定义，并生成 `.d.ts` 文件。它简化了处理不同类型源代码中的类型信息的过程。

## 安装

```bash
npm install extract-types
```

## 使用

在终端中运行以下命令：

```bash
npx extract-types [options] <filepath>
```

### 命令选项

- `-V, --version`: 显示版本号。
- `-o, --output <filepath>`: 指定输出类型定义文件的路径。
- `-t, --type <js|ts|json>`: 指定输入文件类型（默认尝试自动检测）。
- `-h, --help`: 显示帮助信息。

### 示例

```bash
# 从 lib.js 提取类型并保存到 types.d.ts
extract-types lib.js -o types.d.ts

# 从 data.json 提取类型并保存到 types.d.ts
extract-types data.json -o types.d.ts
```

## 功能

`extract-types` 能够：

- 根据输入的 JavaScript、TypeScript 或 JSON 文件，提取其中的类型定义。
- 将类型定义导出到指定的 `.d.ts` 文件中。
- 如果未指定输出文件，结果将默认输出到控制台。

## 许可证

该项目遵循 `MIT` 许可证。

## 问题与支持

- 如遇到问题，请访问 [https://github.com/yuanliwei/extract-types/issues](https://github.com/yuanliwei/extract-types/issues) 创建新问题。
- 查看更多项目信息：[https://github.com/yuanliwei/extract-types](https://github.com/yuanliwei/extract-types#readme)

## 依赖

- `commander`: CLI 参数解析库。
- `typescript`: 用于处理 TypeScript 类型。

## 开发依赖

- `@types/node`: Node.js 的类型定义。

要了解详细信息或贡献代码，请查看 GitHub 仓库。

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