115 lines
3.5 KiB
Markdown
115 lines
3.5 KiB
Markdown
<div align='center'>
|
|
|
|
<h1>TypeBox</h1>
|
|
|
|
<p>Json Schema Type Builder with Static Type Resolution for TypeScript</p>
|
|
|
|
<br />
|
|
<br />
|
|
|
|
[](https://opensource.org/licenses/MIT)
|
|
|
|
</div>
|
|
|
|
## About This Fork
|
|
|
|
This is the **@alkdev/typebox** fork — a community-maintained LTS branch of TypeBox 0.x. The original TypeBox project has been rewritten as 1.x with breaking changes; this fork continues the 0.x API that many projects depend on, with minimal maintenance overhead since the feature set is essentially complete.
|
|
|
|
- **Supply chain security**: Published from our own infrastructure; no dependency on upstream publish access.
|
|
- **Stability**: No breaking rewrites planned. Bug fixes and compatibility patches only.
|
|
- **Drop-in replacement**: `@alkdev/typebox` is API-compatible with `@sinclair/typebox` 0.x.
|
|
|
|
## Overview
|
|
|
|
TypeBox is a runtime type builder that creates in-memory Json Schema objects that infer as TypeScript types. The schematics produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox offers a unified type that can be statically checked by TypeScript and runtime asserted using standard Json Schema validation.
|
|
|
|
This library is designed to allow Json Schema to compose similar to how types compose within TypeScript's type system. It can be used as a simple tool to build up complex schematics or integrated into REST and RPC services to help validate data received over the wire.
|
|
|
|
## Install
|
|
|
|
```bash
|
|
$ npm install @alkdev/typebox
|
|
```
|
|
|
|
See [Installation →](docs/installation.md)
|
|
|
|
## Quick Start
|
|
|
|
```typescript
|
|
import { Type, type Static } from "@alkdev/typebox";
|
|
|
|
const T = Type.Object({
|
|
x: Type.Number(),
|
|
y: Type.Number(),
|
|
z: Type.Number(),
|
|
});
|
|
|
|
type T = Static<typeof T>;
|
|
```
|
|
|
|
See [Usage →](docs/usage.md)
|
|
|
|
## Documentation
|
|
|
|
### Types
|
|
|
|
- [Json Types](docs/types/json.md)
|
|
- [JavaScript Types](docs/types/javascript.md)
|
|
- [Options](docs/types/options.md)
|
|
- [Properties](docs/types/properties.md)
|
|
- [Generic Types](docs/types/generics.md)
|
|
- [Recursive Types](docs/types/recursive.md)
|
|
- [Module Types](docs/types/modules.md)
|
|
- [Template Literal Types](docs/types/template-literal.md)
|
|
- [Indexed Access Types](docs/types/indexed.md)
|
|
- [Mapped Types](docs/types/mapped.md)
|
|
- [Conditional Types](docs/types/conditional.md)
|
|
- [Transform Types](docs/types/transform.md)
|
|
- [Unsafe Types](docs/types/unsafe.md)
|
|
- [TypeGuard](docs/types/typeguard.md)
|
|
|
|
### Values
|
|
|
|
- [Assert](docs/values/assert.md)
|
|
- [Create](docs/values/create.md)
|
|
- [Clone](docs/values/clone.md)
|
|
- [Check](docs/values/check.md)
|
|
- [Convert](docs/values/convert.md)
|
|
- [Clean](docs/values/clean.md)
|
|
- [Default](docs/values/default.md)
|
|
- [Cast](docs/values/cast.md)
|
|
- [Decode / Encode](docs/values/decode-encode.md)
|
|
- [Parse](docs/values/parse.md)
|
|
- [Equal](docs/values/equal.md)
|
|
- [Hash](docs/values/hash.md)
|
|
- [Diff / Patch](docs/values/diff-patch.md)
|
|
- [Errors](docs/values/errors.md)
|
|
- [Mutate](docs/values/mutate.md)
|
|
- [Pointer](docs/values/pointer.md)
|
|
|
|
### Syntax
|
|
|
|
- [Create](docs/syntax/create.md)
|
|
- [Parameters](docs/syntax/parameters.md)
|
|
- [Generics](docs/syntax/generics.md)
|
|
- [Options](docs/syntax/options.md)
|
|
- [NoInfer](docs/syntax/noinfer.md)
|
|
|
|
### Type System
|
|
|
|
- [TypeRegistry](docs/type-registry.md)
|
|
- [TypeCheck](docs/type-check.md) — Ajv, TypeCompiler
|
|
- [TypeMap](docs/type-map.md)
|
|
- [TypeSystem](docs/type-system.md)
|
|
- [Error Function](docs/error-function.md)
|
|
|
|
### Other
|
|
|
|
- [Ecosystem](docs/ecosystem.md)
|
|
- [Benchmark](docs/benchmark.md)
|
|
- [Contributing](docs/contributing.md)
|
|
|
|
## License
|
|
|
|
MIT
|