# hry-types

> typescript工具类型库

Latest version **0.20.3** (published 2026-08-31) · ISC license · 0 weekly downloads

## Install

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

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

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

## Facts

| | |
|---|---|
| Version | 0.20.3 |
| Published | 2026-08-31 |
| First published | 2023-06-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 140.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | missannil |
| Keywords | hry, types, missannil, typescript, type-fest |

## Links

- npm: https://www.npmjs.com/package/hry-types
- npm.io page: https://npm.io/package/hry-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

- 0.20.3 (latest) — 2026-08-31
- 0.20.2 — 2026-08-31
- 0.20.1 — 2026-08-31
- 0.20.0 — 2026-08-30
- 0.19.3 — 2025-05-22
- 0.19.2 — 2025-01-11
- 0.18.1 — 2024-02-01
- 0.18.0 — 2024-01-12
- 0.17.0 — 2023-12-02
- 0.16.12 — 2023-10-06
- 0.16.11 — 2023-09-18
- 0.16.10 — 2023-09-18
- 0.16.9 — 2023-08-28
- 0.16.8 — 2023-08-12
- 0.16.7 — 2023-08-09
- … 31 more at https://npm.io/package/hry-types/versions

## README

## 简介

<a href="#">
  <img src="https://img.shields.io/badge/npm-you_like-blue>"
</a>
hry-types 是由恒荣耀(hry)团队开发的typescript类型工具库。

## 特点

- 项目中注释和文档等全部使用中文。

- 严格泛型与宽泛泛型
  对于需要校验参数类型的泛型,提供两个版本:原泛型负责对外提供严格的参数约束,带下划线前缀的泛型去除参数约束,用于其他泛型内部组合。严格版本统一转发给宽泛版本实现。
  ```ts
  import type { _MergeUnion, MergeUnion } from "hry-types";

  type User = { id: string };
  type Admin = { id: number; name: string };

  // 对外使用严格版本,传入参数会进行普通对象校验
  type UserAndAdmin = MergeUnion<User, Admin>;

  // 其他泛型内部已经完成参数校验时,使用宽泛版本避免中间类型再次触发约束
  type MergeResult<T, U> = _MergeUnion<T, U>;
  ```
  宽泛版本使用单个下划线前缀,严格版本和宽泛版本的实现保持一致。下划线版本主要用于类型工具之间的组合,直接对外使用时应优先选择严格版本。

## 安装

```bash
pnpm add hry-types -D
```

## tsconfig

```json
// tsconfig.json
{
  "compilerOptions": {
    // ...
    "types": ["hry-types"]
  }
}
```

## 使用示例

```ts
import { type A } from "hry-types";
import type { IfEquals } from "hry-types/src/Any/IfEquals";

type foo<T extends string | number> = A.IfEquals<T, string, "string", "number">;
// type foo<T extends string | number> = IfEquals<T, string, "string", "number">

type test = foo<string>; // test => 'string'

type test2 = foo<number>; // test2 => 'number'
```

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