[PR #6852] [MERGED] docs: fix RequestInit body typing for exactOptionalPropertyTypes #15169

Closed
opened 2026-04-13 09:51:57 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6852
Author: @SkyZonDev
Created: 12/18/2025
Status: Merged
Merged: 12/24/2025
Merged by: @himself65

Base: canaryHead: docs/fix-requestinit-body


📝 Commits (1)

  • 01d7ee6 docs: fix RequestInit body typing for exactOptionalPropertyTypes

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 docs/content/docs/integrations/fastify.mdx (+1 -1)

📄 Description

Summary

This PR updates documentation examples to be compatible with TypeScript
projects using "exactOptionalPropertyTypes": true.

Some examples were passing body: undefined to RequestInit, which causes
a TypeScript error in strict configurations.


What changed and why

  • Updated Fetch / Request examples to omit the body property entirely
    when no request body is present.
  • Added a short TypeScript note explaining why body: undefined should be
    avoided.

This aligns the documentation with the Fetch spec and strict TypeScript
settings.


Context / Background

With exactOptionalPropertyTypes enabled, optional properties must be omitted
instead of being explicitly set to undefined.

Users copying the existing examples would encounter the following error:

TS2379: Type 'string | undefined' is not assignable to type 'BodyInit'

Breaking changes or deprecations

  • None

UI changes

  • None (documentation-only change)

  • N/A

Summary by cubic

Fix RequestInit body typing in the Fastify docs so TypeScript projects with exactOptionalPropertyTypes compile without errors. Replaces body: undefined with a conditional spread to include body only when present.

Written for commit 01d7ee6ceb. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/6852 **Author:** [@SkyZonDev](https://github.com/SkyZonDev) **Created:** 12/18/2025 **Status:** ✅ Merged **Merged:** 12/24/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `docs/fix-requestinit-body` --- ### 📝 Commits (1) - [`01d7ee6`](https://github.com/better-auth/better-auth/commit/01d7ee6ceb3af50171c27b946d366cca9fc22014) docs: fix RequestInit body typing for exactOptionalPropertyTypes ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/integrations/fastify.mdx` (+1 -1) </details> ### 📄 Description ### Summary This PR updates documentation examples to be compatible with TypeScript projects using `"exactOptionalPropertyTypes": true`. Some examples were passing `body: undefined` to `RequestInit`, which causes a TypeScript error in strict configurations. --- ### What changed and why - Updated Fetch / `Request` examples to **omit the `body` property entirely** when no request body is present. - Added a short TypeScript note explaining why `body: undefined` should be avoided. This aligns the documentation with the Fetch spec and strict TypeScript settings. --- ### Context / Background With `exactOptionalPropertyTypes` enabled, optional properties must be omitted instead of being explicitly set to `undefined`. Users copying the existing examples would encounter the following error: ```ts TS2379: Type 'string | undefined' is not assignable to type 'BodyInit' ``` --- ### Breaking changes or deprecations - None --- ### UI changes - None (documentation-only change) --- ### Related issues or discussions - N/A <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fix RequestInit body typing in the Fastify docs so TypeScript projects with exactOptionalPropertyTypes compile without errors. Replaces body: undefined with a conditional spread to include body only when present. <sup>Written for commit 01d7ee6ceb3af50171c27b946d366cca9fc22014. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 09:51:57 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#15169