Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions examples/00-basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ if (result.data === null) {
// but it is typed as Record<string, string | File>.
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");
Expand Down
1 change: 0 additions & 1 deletion examples/01-file-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down