Why Type Safety Matters
Type safety prevents entire classes of bugs before they reach production:Catch Errors Early
TypeScript catches type mismatches during development, not in production.
Better IntelliSense
Your IDE provides accurate autocomplete and inline documentation.
Refactor Safely
Change APIs with confidence knowing TypeScript will flag breaking changes.
Runtime Validation
Zod validates data at runtime, protecting against invalid API responses.
TypeScript Benefits
Full Type Coverage
Every SDK method has complete TypeScript definitions:IntelliSense Support
Your IDE provides intelligent code completion:Compile-Time Error Detection
TypeScript catches mistakes before runtime:Zod Runtime Validation
While TypeScript provides compile-time safety, Zod validates data at runtime. This is crucial for:- API responses that might not match expected schemas
- User input that bypasses TypeScript
- Third-party data from webhooks or external sources
How Zod Works
Zod schemas define the shape and validation rules for data. Here’s an example fromsrc/zod/transaction.ts:15-85:
src/zod/transaction.ts
Input Validation
Zod automatically validates all inputs before API requests:Output Validation
Zod also validates API responses to ensure they match the expected schema:src/main/transaction.ts
Type Inference
Zod schemas can be converted to TypeScript types usingz.infer. From src/zod/transaction.ts:1503-1517:
src/zod/transaction.ts
Importing Types
You can import types for use in your application:Common Types
The SDK exports many reusable types fromsrc/zod/index.ts:228-237:
src/zod/index.ts
Validation Schemas
Currency Validation
The SDK validates currency codes fromsrc/zod/index.ts:40-49:
src/zod/index.ts
Email Validation
Emails are validated using Zod’s built-in email validator:URL Validation
Callback URLs are validated as proper URLs:Custom Object Validation
Fromsrc/zod/index.ts:127-147, the SDK validates complex nested objects:
src/zod/index.ts
Advanced Type Patterns
Discriminated Unions
Handle different response types safely:Generic Helpers
Create type-safe wrappers:Utility Types
Use TypeScript utility types with SDK types:Schema Composition
Zod schemas can be composed and extended:Safe Parsing
Manually validate data using Zod schemas:Best Practices
Trust the Types
Let TypeScript guide you. If something doesn’t type-check, there’s usually a good reason.
Import Types
Import types for reusability and consistency across your codebase.
Handle Validation Errors
Always check for validation errors in the result object.
Use Strict Mode
Enable strict TypeScript settings in
tsconfig.json:Platform Support
The SDK is fully typed for all JavaScript runtimes:- Node.js
- Bun
- Deno
- Cloudflare Workers
TypeScript Configuration
Recommendedtsconfig.json for best experience:
tsconfig.json
Next Steps
API Reference
Explore detailed API documentation with type information
Error Handling
Learn how to handle validation and runtime errors

