1+ import { Future } from "../types/future" ;
12import type { Equal , Expect } from "../types/utils" ;
23import type { Location , Path , To } from "./history" ;
34import { invariant , parsePath , warning } from "./history" ;
@@ -172,6 +173,10 @@ export class unstable_RouterContextProvider {
172173 }
173174}
174175
176+ type DefaultContext = Future extends { unstable_middleware : true }
177+ ? unstable_RouterContextProvider
178+ : any ;
179+
175180/**
176181 * @private
177182 * Arguments passed to route loader/action functions. Same for now but we keep
@@ -225,13 +230,13 @@ export type unstable_MiddlewareFunction<Result = unknown> = (
225230/**
226231 * Arguments passed to loader functions
227232 */
228- export interface LoaderFunctionArgs < Context = any >
233+ export interface LoaderFunctionArgs < Context = DefaultContext >
229234 extends DataFunctionArgs < Context > { }
230235
231236/**
232237 * Arguments passed to action functions
233238 */
234- export interface ActionFunctionArgs < Context = any >
239+ export interface ActionFunctionArgs < Context = DefaultContext >
235240 extends DataFunctionArgs < Context > { }
236241
237242/**
@@ -244,7 +249,7 @@ type DataFunctionReturnValue = MaybePromise<DataFunctionValue>;
244249/**
245250 * Route loader function signature
246251 */
247- export type LoaderFunction < Context = any > = {
252+ export type LoaderFunction < Context = DefaultContext > = {
248253 (
249254 args : LoaderFunctionArgs < Context > ,
250255 handlerCtx ?: unknown
@@ -254,7 +259,7 @@ export type LoaderFunction<Context = any> = {
254259/**
255260 * Route action function signature
256261 */
257- export interface ActionFunction < Context = any > {
262+ export interface ActionFunction < Context = DefaultContext > {
258263 (
259264 args : ActionFunctionArgs < Context > ,
260265 handlerCtx ?: unknown
@@ -339,7 +344,7 @@ export interface DataStrategyMatch
339344 ) => Promise < DataStrategyResult > ;
340345}
341346
342- export interface DataStrategyFunctionArgs < Context = any >
347+ export interface DataStrategyFunctionArgs < Context = DefaultContext >
343348 extends DataFunctionArgs < Context > {
344349 matches : DataStrategyMatch [ ] ;
345350 fetcherKey : string | null ;
@@ -353,7 +358,7 @@ export interface DataStrategyResult {
353358 result : unknown ; // data, Error, Response, DeferredData, DataWithResponseInit
354359}
355360
356- export interface DataStrategyFunction < Context = any > {
361+ export interface DataStrategyFunction < Context = DefaultContext > {
357362 ( args : DataStrategyFunctionArgs < Context > ) : Promise <
358363 Record < string , DataStrategyResult >
359364 > ;
0 commit comments