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

View File

@@ -0,0 +1,36 @@
[Overview](../overview.md) | [Installation](../installation.md) | [Usage](../usage.md) | **Types** | [Values](../values/) | [Syntax](../syntax/) | [TypeRegistry](../type-registry.md) | [TypeCheck](../type-check.md)
# Template Literal Types
TypeBox supports template literal types with the TemplateLiteral function. This type can be created using a syntax similar to the TypeScript template literal syntax or composed from exterior types. TypeBox encodes template literals as regular expressions which enables the template to be checked by Json Schema validators. This type also supports regular expression parsing that enables template patterns to be used for generative types. The following shows both TypeScript and TypeBox usage.
```typescript
// TypeScript
type K = `prop${"A" | "B" | "C"}`; // type T = 'propA' | 'propB' | 'propC'
type R = Record<K, string>; // type R = {
// propA: string
// propB: string
// propC: string
// }
// TypeBox
const K = Type.TemplateLiteral("prop${A|B|C}"); // const K: TTemplateLiteral<[
// TLiteral<'prop'>,
// TUnion<[
// TLiteral<'A'>,
// TLiteral<'B'>,
// TLiteral<'C'>,
// ]>
// ]>
const R = Type.Record(K, Type.String()); // const R: TObject<{
// propA: TString,
// propB: TString,
// propC: TString,
// }>
```
Back to [Home](../../readme.md)