Add TypeScript testing and error handling documentation#31
Merged
Conversation
… doc Three major how-to guides (programmatic usage, error handling, testing) previously covered only Python and Java with zero TypeScript content. This adds comprehensive TypeScript sections to all three, creates a dedicated TypeScript error handling guide (mirroring the existing Python-specific guide), and adds cross-reference links throughout. - Add TypeScript sections to using-the-cycles-client-programmatically.md - Add TypeScript sections to error-handling-patterns-in-cycles-client-code.md - Create error-handling-patterns-in-typescript.md (Express, Next.js patterns) - Add TypeScript section to testing-with-cycles.md (Vitest, mocking patterns) - Add cross-reference links in quickstart and existing guides https://claude.ai/code/session_01AioSM8RvRKCXgRsV6m75Mm
- Add 'Error Handling in TypeScript' to VitePress sidebar config - Add missing isToolAllowed import in TypeScript error handling guide https://claude.ai/code/session_01AioSM8RvRKCXgRsV6m75Mm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive TypeScript documentation for testing Cycles-governed code and error handling patterns, bringing TypeScript documentation to feature parity with Python and Java guides.
Key Changes
New TypeScript Testing Guide: Added extensive section to
testing-with-cycles.mdcovering:withCycles-wrapped functionsCyclesClientwith Vitest (vi.fn())fetchfor integration testswithCyclesfull lifecycle with mocked HTTPreserveForStreamstreaming handle behaviorNew TypeScript Error Handling Guide: Created
error-handling-patterns-in-typescript.mdwith:CyclesProtocolError,CyclesTransportError, and specific subclasses)withCyclesandreserveForStreamUpdated Cross-Language Guides:
error-handling-patterns-in-cycles-client-code.md: Added TypeScript examples alongside Python and Java for all error handling patterns (DENY decisions, degradation, debt/overdraft, expired reservations, catching all errors, web framework handlers, programmatic client errors)using-the-cycles-client-programmatically.md: Added TypeScript examples for all programmatic client operations (initialization, creating/committing/releasing reservations, preflight decisions, querying balances, listing reservations, recording events)testing-with-cycles.md: Updated tips section to reference TypeScript-specific mocking approachesNotable Implementation Details
vi.fn()for mocking andvi.stubGlobal()for fetch mockingwithCyclesHOF) and programmatic (CyclesClient) approacheshttps://claude.ai/code/session_01AioSM8RvRKCXgRsV6m75Mm