百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
T

typia

> 数据库
开源

通过转换实现超快/超简单的运行时验证器和序列化器

5.9K stars0 点赞2 次浏览
访问官网GitHub

工具介绍

通过转换实现超快/超简单的运行时验证器和序列化器

Typia

…

typia 是一个支持以下功能的 Transformer 库:

  • 超快运行时验证器
  • 增强的 JSON schema 和序列化/反序列化函数
  • LLM 函数调用工具
  • Protocol Buffer 编码器和解码器
  • 随机数据生成器

[!NOTE]

  • 只需一行代码,使用纯 TypeScript 类型
  • 运行时验证器比 class-validator 快 20,000 倍
  • JSON 序列化比 class-Transformer 快 200 倍
  • LLM 函数调用工具将准确率从 6.75% 提升至 100%

在左侧编写类型,typia 会在构建时将其编译为右侧的验证器——无需 schema,也无需运行时反射。

设置

使用 ttsc 工具链安装 typia。

bash
# install
npm i typia
npm i -D ttsc typescript

# build
npx ttsc

# run a script directly
npx ttsx src/index.ts

你必须使用 ttsc 和 ttsx。原生的 tsc、ts-node 和 tsx 无法应用 typia 转换,因此它们无法工作。

关于打包工具集成(Vite、Next.js、Webpack、Rollup、esbuild 等),请使用 @ttsc/unplugin。

转换

如果你调用 typia 函数,它会被编译成如下形式。

这是 typia 的核心概念:将 TypeScript 类型转换为运行时函数。typia.is<T>() 函数会在编译层面分析目标类型 T,从而被转换为一个专用的类型检查器。

此功能使开发者能够在其的应用程序中确保类型安全,利用 TypeScript 的静态类型,同时还提供运行时验证。无需定义额外的 schema,你可以直接使用纯 TypeScript 类型本身。

typescript
//----
// examples/checkString.ts
//----
import typia, { tags } from "typia";
export const checkString = typia.createIs<string>();

//----
// examples/checkString.js
//----
import typia from "typia";
export const checkString = (() => {
  return (input) => "string" === typeof input;
})();

赞助商

感谢你的支持。

你的捐赠是对 typia 开发的鼓励。

Playground(演练场)

你可以体验

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptagentic-aiajvcheckerfast

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库