Response Type Inference
Use TypeScript generics to specify the expected response type:Nested Response Types
For APIs that wrap data in a response envelope:Array Responses
Response Type with responseType Option
The second generic parameter allows you to specify the response format:Type-Safe API Client
Create a fully typed API client:Hooks with Type Safety
Hooks are also fully typed:Error Handling with Types
Type Definitions
Fromsrc/types.ts:5-16:
MappedResponseType helper (from src/types.ts:132-135):
responseType: 'blob'→ returnsBlobresponseType: 'text'→ returnsstringresponseType: 'arrayBuffer'→ returnsArrayBufferresponseType: 'stream'→ returnsReadableStream<Uint8Array>responseType: 'json'(default) → returns your generic typeT