From 802076516f20344d65759418dcc5f0e4a7651349 Mon Sep 17 00:00:00 2001 From: roottool Date: Mon, 29 Dec 2025 10:07:35 +0900 Subject: [PATCH] docs: improve examples documentation and remove redundant comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add Usage Examples section to CLAUDE.md with directory overview - Include type checking command for examples - Remove redundant type annotation comments from example files - Improve code clarity by relying on TypeScript's type inference 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- CLAUDE.md | 16 ++++++++++++++++ examples/00-basic.ts | 2 -- examples/01-file-upload.ts | 1 - 3 files changed, 16 insertions(+), 3 deletions(-) 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