1
+ import type { MiddlewareEnabled } from "../types/future" ;
1
2
import type { Equal , Expect } from "../types/utils" ;
2
3
import type { Location , Path , To } from "./history" ;
3
4
import { invariant , parsePath , warning } from "./history" ;
@@ -172,6 +173,10 @@ export class unstable_RouterContextProvider {
172
173
}
173
174
}
174
175
176
+ type DefaultContext = MiddlewareEnabled extends true
177
+ ? unstable_RouterContextProvider
178
+ : any ;
179
+
175
180
/**
176
181
* @private
177
182
* Arguments passed to route loader/action functions. Same for now but we keep
@@ -225,13 +230,13 @@ export type unstable_MiddlewareFunction<Result = unknown> = (
225
230
/**
226
231
* Arguments passed to loader functions
227
232
*/
228
- export interface LoaderFunctionArgs < Context = any >
233
+ export interface LoaderFunctionArgs < Context = DefaultContext >
229
234
extends DataFunctionArgs < Context > { }
230
235
231
236
/**
232
237
* Arguments passed to action functions
233
238
*/
234
- export interface ActionFunctionArgs < Context = any >
239
+ export interface ActionFunctionArgs < Context = DefaultContext >
235
240
extends DataFunctionArgs < Context > { }
236
241
237
242
/**
@@ -244,7 +249,7 @@ type DataFunctionReturnValue = MaybePromise<DataFunctionValue>;
244
249
/**
245
250
* Route loader function signature
246
251
*/
247
- export type LoaderFunction < Context = any > = {
252
+ export type LoaderFunction < Context = DefaultContext > = {
248
253
(
249
254
args : LoaderFunctionArgs < Context > ,
250
255
handlerCtx ?: unknown
@@ -254,7 +259,7 @@ export type LoaderFunction<Context = any> = {
254
259
/**
255
260
* Route action function signature
256
261
*/
257
- export interface ActionFunction < Context = any > {
262
+ export interface ActionFunction < Context = DefaultContext > {
258
263
(
259
264
args : ActionFunctionArgs < Context > ,
260
265
handlerCtx ?: unknown
@@ -354,7 +359,7 @@ export interface DataStrategyMatch
354
359
) => Promise < DataStrategyResult > ;
355
360
}
356
361
357
- export interface DataStrategyFunctionArgs < Context = any >
362
+ export interface DataStrategyFunctionArgs < Context = DefaultContext >
358
363
extends DataFunctionArgs < Context > {
359
364
matches : DataStrategyMatch [ ] ;
360
365
// TODO: Implement
@@ -370,7 +375,7 @@ export interface DataStrategyResult {
370
375
result : unknown ; // data, Error, Response, DeferredData, DataWithResponseInit
371
376
}
372
377
373
- export interface DataStrategyFunction < Context = any > {
378
+ export interface DataStrategyFunction < Context = DefaultContext > {
374
379
( args : DataStrategyFunctionArgs < Context > ) : Promise <
375
380
Record < string , DataStrategyResult >
376
381
> ;
0 commit comments