Skip to main content

Overview

You can augment the FetchOptions interface to add custom properties with full TypeScript support. This is useful for adding domain-specific options that work throughout your application.

Basic Usage

Place this in any .ts or .d.ts file in your project:
Ensure the file is included in your tsconfig.json “files” or covered by “include” patterns.

Using Augmented Types

Once augmented, your custom properties are available everywhere:

Example from README

From README.md:356-384:
This lets you pass and use those properties with full type safety throughout ofetch calls:

Common Use Cases

Authentication Requirements

Cache Control

Rate Limiting

API Versioning

Request Tracking

Multiple Augmentations

You can augment the interface multiple times:
Both properties will be available:

Context Types

From src/types.ts:94-99:
Your augmented properties are available in interceptors through context.options:

Best Practices

1. Use Optional Properties

2. Document Your Properties

3. Keep Type Files Organized

4. Export Empty Object

tsconfig.json Setup

Make sure your type declaration files are included:

Complete Example