[PR #3994] [MERGED] fix(sveltekit): use permissive typing for RequestEvent params #5125

Closed
opened 2026-03-13 12:11:32 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3994
Author: @n00ki
Created: 8/14/2025
Status: Merged
Merged: 8/15/2025
Merged by: @Bekacru

Base: canaryHead: fix/relax-sveltekit-requestevent


📝 Commits (1)

  • aefd331 fix(sveltekit): use permissive typing for RequestEvent params

📊 Changes

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

View changed files

📝 packages/better-auth/src/integrations/svelte-kit.ts (+1 -4)

📄 Description

The sveltekitCookies plugin fails with TypeScript errors (if "strict": true / "strictNullChecks": true) due to recent changes in SvelteKit's type system, where RequestEvent parameters are now more strictly typed.

Root Cause

SvelteKit commit a8cc450 made route parameter types more precise.
For routes without parameters (like "/"), LayoutParams<"/"> can now be undefined, which doesn't satisfy the previous constraint Partial<Record<string, string>>.

Solution

Updated RequestEvent type parameters to use any:

  • From: RequestEvent<Partial<Record<string, string>>, string | null>
  • To: RequestEvent<any, any>

This change:

  • Fixes the TypeScript error
  • Maintains backward compatibility
  • Doesn't affect runtime behavior (Better-Auth only uses event.cookies, never the route parameters)

Breaking Changes

None - this is a type-only fix that maintains full backward compatibility.


Summary by cubic

Relaxed the type definitions for SvelteKit's RequestEvent params to fix TypeScript errors when using strict mode.

  • Bug Fixes
  • Updated sveltekitCookies to use permissive typings, preventing type errors on routes without parameters.

🔄 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/3994 **Author:** [@n00ki](https://github.com/n00ki) **Created:** 8/14/2025 **Status:** ✅ Merged **Merged:** 8/15/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/relax-sveltekit-requestevent` --- ### 📝 Commits (1) - [`aefd331`](https://github.com/better-auth/better-auth/commit/aefd331b61d30cedf871aeb3f525800b0af097a2) fix(sveltekit): use permissive typing for RequestEvent params ### 📊 Changes **1 file changed** (+1 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/integrations/svelte-kit.ts` (+1 -4) </details> ### 📄 Description The `sveltekitCookies` plugin fails with TypeScript errors (if `"strict": true` / `"strictNullChecks": true`) due to recent changes in SvelteKit's type system, where `RequestEvent` parameters are now more strictly typed. ### Root Cause SvelteKit commit [a8cc450](https://github.com/sveltejs/kit/commit/a8cc450f7ab4d4481276219cfe23363d6ae4f51e) made route parameter types more precise. For routes without parameters (like `"/"`), `LayoutParams<"/">` can now be `undefined`, which doesn't satisfy the previous constraint `Partial<Record<string, string>>`. ### Solution Updated `RequestEvent` type parameters to use `any`: - From: `RequestEvent<Partial<Record<string, string>>, string | null>` - To: `RequestEvent<any, any>` This change: - Fixes the TypeScript error - Maintains backward compatibility - Doesn't affect runtime behavior (Better-Auth only uses `event.cookies`, never the route parameters) ### Breaking Changes None - this is a type-only fix that maintains full backward compatibility. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Relaxed the type definitions for SvelteKit's RequestEvent params to fix TypeScript errors when using strict mode. - **Bug Fixes** - Updated sveltekitCookies to use permissive typings, preventing type errors on routes without parameters. <!-- 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-03-13 12:11:32 -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#5125