What this prompt does
This prompt builds a TypeScript utility-types library for a [project_type]. It generates DeepPartial, DeepRequired, and DeepReadonly for nested objects; branded/nominal types for [branded_types] to stop value mixing; a type-safe event emitter with autocomplete for event names and payloads; StrictOmit and StrictPick that error on non-existent keys; a PathValue type for dot-notation access; builder-pattern types with compile-time validation; a discriminated-union API response wrapper; and an exhaustive assertNever helper. Each type ships with JSDoc, a usage example, and unit tests using [test_framework], exported from a single barrel file.
The structure works because strong types pay off most in shared libraries the whole codebase leans on. Branded IDs from [branded_types] make it impossible to pass a UserId where an OrderId belongs; the type-safe emitter and discriminated-union wrapper catch mistakes at compile time rather than in production. Pairing each utility with type-level tests keeps the library honest as it grows.
When to use it
- You want a shared utility-types foundation for a
[project_type]. - You need branded types to prevent mixing IDs, emails, or currencies.
- You want a type-safe event emitter with autocomplete for events and payloads.
- You need stricter Omit/Pick that error on typo'd keys.
- You want a discriminated-union wrapper for success/error API responses.
- You want each utility documented and covered by type-level tests.
Example output
You get a TypeScript library with one file per utility (or grouped sensibly), each carrying JSDoc and a usage example: deep object helpers, branded types for [branded_types], a typed event emitter, StrictOmit/StrictPick, PathValue, builder types, an API response union, and assertNever. A [test_framework] test file with type-level assertions accompanies them, all re-exported from an index barrel.
Pro tips
- Choose
[branded_types]for values that are genuinely interchangeable by accident — IDs, emails, currency amounts. - Use the discriminated-union API wrapper everywhere your code handles responses so error cases are exhaustively checked.
- Lean on assertNever in switch statements to get compile errors when a new variant is added but unhandled.
- Keep the JSDoc usage examples accurate; they are how the rest of the team learns the utilities.
- Pick a
[test_framework]that supports type-level testing so the library's guarantees are actually verified. - Export through the barrel file but watch for circular imports as the library grows.