Decompose monolithic readme into docs/ directory structure

This commit is contained in:
2026-04-23 13:57:56 +00:00
parent 560bb00433
commit f8b2cdd5a4
47 changed files with 1936 additions and 1829 deletions

41
docs/types/indexed.md Normal file
View File

@@ -0,0 +1,41 @@
[Overview](../overview.md) | [Installation](../installation.md) | [Usage](../usage.md) | **Types** | [Values](../values/) | [Syntax](../syntax/) | [TypeRegistry](../type-registry.md) | [TypeCheck](../type-check.md)
# Indexed Access Types
TypeBox supports indexed access types with the Index function. This function enables uniform access to interior property and element types without having to extract them from the underlying schema representation. Index types are supported for Object, Array, Tuple, Union and Intersect types.
```typescript
const T = Type.Object({
// type T = {
x: Type.Number(), // x: number,
y: Type.String(), // y: string,
z: Type.Boolean(), // z: boolean
}); // }
const A = Type.Index(T, ["x"]); // type A = T['x']
//
// ... evaluated as
//
// const A: TNumber
const B = Type.Index(T, ["x", "y"]); // type B = T['x' | 'y']
//
// ... evaluated as
//
// const B: TUnion<[
// TNumber,
// TString,
// ]>
const C = Type.Index(T, Type.KeyOf(T)); // type C = T[keyof T]
//
// ... evaluated as
//
// const C: TUnion<[
// TNumber,
// TString,
// TBoolean
// ]>
```
Back to [Home](../../readme.md)