@arktype/schema

中文文档
0.56.8发布于 2026/10/21MITTypeScriptES Module构建来源已验证近 30 天下载 3.8万

Underlying schema language parsed from arktype syntax.

原始使用文档

@ark/schema

Underlying schema language parsed from arktype syntax.

The parts of ArkType's type system that exist in TS (i.e. not runtime-only constraints like bounds, divisors, custom predicates, morphs etc.) are structured like this:

  • Union: a set of intersections
  • Intersection: a set of a basis and constraints
  • Basis: this is the base type to which refinements like props are applied. It is one of three things, getting narrower as you move down the list:
    • Domain: "string" | "number" | "bigint" | "object" | "symbol" parallels built-in TS keywords for non-enumerable value sets
    • Proto: Must be an instanceof some class (implies domain "object")
    • Unit: Must === some value (can be intersected with any other constraint and reduced to itself or a disjoint)
  • Constraint: an individual condition that must be satisfied:
    • Required: must have a specified literal string or symbol key and a value that conforms to a specified union or intersection
    • Optional: Required conditions met or the specified key is not present
    • Index: all keys that satisfy an index type must have values satisfying the corresponding value type

In this system, L extends/subtypes/is assignable to R if and only if the intersection L & R is equal to L.

版本与发布记录

@arktype/schema 共发布 114 个版本,首次发布于 2023/11/18;过去 12 个月发布了 10 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.56.8latest2026/10/2118 天前
0.56.72026/10/0830 天前
0.56.62026/10/021 个月前
0.56.52026/10/011 个月前
0.56.42026/09/251 个月前
0.56.22026/07/084 个月前

其他发布通道:cjs → 0.1.4-cjs。

关于 @arktype/schema 的常见问题

@arktype/schema 是什么?

Underlying schema language parsed from arktype syntax.

如何安装 @arktype/schema?

在项目目录运行 npm install @arktype/schema,或使用 pnpm add / yarn add / bun add。

@arktype/schema 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@arktype/schema 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@arktype/schema 可以商用吗?

@arktype/schema 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@arktype/schema 的下载量有多少?

根据 npm 官方下载统计,@arktype/schema 在 2026/10/07 – 2026/11/05 这 30 天内被下载 37,708 次,日均约 1,257 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@arktype/schema 还在维护吗?

最新版本 0.56.8 发布于 2026/10/21(18 天前);至今共发布 114 个版本,其中过去 12 个月发布了 10 个;首次发布于 2023/11/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。