#6869·axios

Improve fetchOptions type definition for better autocomplete, type safety, Next.js extensions

Author: vgotu99Created Apr 10, 2025Updated Jul 4, 2026
Labelstype::breaking

Description:

currently, the fetchOptions type in Axios is defined as Record<string, any>, which limits IDE autocompletion and type safety. This issue proposes updating the type to RequestInit, the standard interface used by the Fetch API. Additionally, Next.js extends the RequestInit interface with custom options like cache and next, making this change more relevant for developers using Axios in Next.js projects.

Why this matters:

  • Improved Autocompletion
    • using RequestInit provides developers with context-aware suggestions in IDEs.
  • Type Safety
    • ensures stricter type checking and reduces runtime errors.
  • Next.js Compatibility

Proposed Solution:

  • Replace the current type definition of fetchOptions with RequestInit.
  • Ensure compatibility with Next.js extensions by leveraging its extended interface.

Benefits:

  • Aligns Axios with Fetch API standards.
  • Enhances developer experience, especially for Next.js users.
  • Provides a safer and more predictable API.