diff --git a/CLAUDE.md b/CLAUDE.md index 2e967eb..dfc818c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -34,6 +34,22 @@ Key resources: - Design decisions (Why no structural inference?, etc.) - Versioning policy +## Usage Examples + +The `examples/` directory contains comprehensive usage examples: + +- `00-basic.ts` - Basic parsing and type narrowing +- `01-file-upload.ts` - File handling with type guards +- `02-field-presence.ts` - Field presence checks +- `03-error-handling.ts` - Validation issue handling +- `04-integration-fetch.ts` - Integration with Request/Fetch API + +Run type checking for examples: + +```bash +bun run check:type:example +``` + ## Development Commands ### Setup diff --git a/examples/00-basic.ts b/examples/00-basic.ts index c14c7e0..35858c7 100644 --- a/examples/00-basic.ts +++ b/examples/00-basic.ts @@ -23,14 +23,12 @@ if (result.data === null) { // but it is typed as Record. const data = result.data; -// name: string | File const name = data["name"]; if (typeof name !== "string") { throw new Error("Expected name to be a string"); } name.toUpperCase(); -// age: string | File const age = data["age"]; if (typeof age !== "string") { throw new Error("Expected age to be a string"); diff --git a/examples/01-file-upload.ts b/examples/01-file-upload.ts index 7da069b..e01bdb3 100644 --- a/examples/01-file-upload.ts +++ b/examples/01-file-upload.ts @@ -29,7 +29,6 @@ if (result.data === null) { // but values are still typed as string | File. const data = result.data; -// avatar: string | File const avatar = data["avatar"]; // Narrow to File before accessing file-specific properties