1
+ // Disabling `no-explicit-any` for the whole file as `any` has became common requirement.
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
3
import { Transaction , TransactionContext } from '@sentry/types' ;
2
4
3
- export type Action = 'PUSH' | 'REPLACE' | 'POP' ;
5
+ export enum Action {
6
+ Pop = 'POP' ,
7
+ Push = 'PUSH' ,
8
+ Replace = 'REPLACE' ,
9
+ }
4
10
5
11
export type Location = {
6
12
pathname : string ;
7
13
action ?: Action ;
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
14
} & Record < string , any > ;
10
15
11
16
export type ReactRouterInstrumentation = < T extends Transaction > (
@@ -19,15 +24,15 @@ export interface NonIndexRouteObject {
19
24
caseSensitive ?: boolean ;
20
25
children ?: RouteObject [ ] ;
21
26
element ?: React . ReactNode | null ;
22
- index ?: false ;
27
+ index ?: any ;
23
28
path ?: string ;
24
29
}
25
30
26
31
export interface IndexRouteObject {
27
32
caseSensitive ?: boolean ;
28
33
children ?: undefined ;
29
34
element ?: React . ReactNode | null ;
30
- index : true ;
35
+ index : any ;
31
36
path ?: string ;
32
37
}
33
38
@@ -69,9 +74,7 @@ export type UseNavigationType = () => Action;
69
74
// For both of these types, use `any` instead of `RouteObject[]` or `RouteMatch[]`.
70
75
// Have to do this so we maintain backwards compatability between
71
76
// react-router > 6.0.0 and >= 6.4.2.
72
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
77
export type RouteObjectArrayAlias = any ;
74
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
78
export type RouteMatchAlias = any ;
76
79
export type CreateRoutesFromChildren = ( children : JSX . Element [ ] ) => RouteObjectArrayAlias ;
77
80
export type MatchRoutes = ( routes : RouteObjectArrayAlias , location : Location ) => RouteMatchAlias [ ] | null ;
@@ -104,15 +107,9 @@ declare type AgnosticBaseRouteObject = {
104
107
handle ?: any ;
105
108
} ;
106
109
107
- export declare type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
108
- children ?: undefined ;
109
- index : true ;
110
- } ;
110
+ export declare type AgnosticIndexRouteObject = AgnosticBaseRouteObject & Record < string , any > ;
111
111
112
- export declare type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
113
- children ?: AgnosticRouteObject [ ] ;
114
- index ?: false ;
115
- } ;
112
+ export declare type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & Record < string , any > ;
116
113
117
114
export declare type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
118
115
id : string ;
@@ -183,50 +180,39 @@ declare type SubmissionNavigateOptions = {
183
180
} ;
184
181
185
182
export interface RouterInit {
186
- basename ? : string ;
183
+ basename : string ;
187
184
routes : AgnosticRouteObject [ ] ;
188
185
history : History ;
189
186
hydrationData ?: HydrationState ;
190
187
}
191
188
192
189
export type NavigationStates = {
193
- Idle : {
194
- state : 'idle' ;
195
- location : undefined ;
196
- formMethod : undefined ;
197
- formAction : undefined ;
198
- formEncType : undefined ;
199
- formData : undefined ;
200
- } ;
201
- Loading : {
202
- state : 'loading' ;
203
- location : Location ;
204
- formMethod : FormMethod | undefined ;
205
- formAction : string | undefined ;
206
- formEncType : FormEncType | undefined ;
207
- formData : FormData | undefined ;
208
- } ;
209
- Submitting : {
210
- state : 'submitting' ;
211
- location : Location ;
212
- formMethod : FormMethod ;
213
- formAction : string ;
214
- formEncType : FormEncType ;
215
- formData : FormData ;
216
- } ;
190
+ Idle : any ;
191
+ Loading : any ;
192
+ Submitting : any ;
217
193
} ;
218
194
219
195
export type Navigation = NavigationStates [ keyof NavigationStates ] ;
220
196
197
+ export type RouteData = any ;
198
+ export type Fetcher = any ;
199
+
221
200
export interface RouterState {
222
201
historyAction : Action ;
223
- location : Location ;
202
+ location : any ;
224
203
matches : AgnosticDataRouteMatch [ ] ;
225
204
initialized : boolean ;
226
205
navigation : Navigation ;
206
+ restoreScrollPosition : number | false | null ;
207
+ preventScrollReset : boolean ;
208
+ revalidation : any ;
209
+ loaderData : RouteData ;
210
+ actionData : RouteData | null ;
211
+ errors : RouteData | null ;
212
+ fetchers : Map < string , Fetcher > ;
227
213
}
228
214
export interface Router {
229
- basename : string ;
215
+ basename : string | undefined ;
230
216
state : RouterState ;
231
217
routes : AgnosticDataRouteObject [ ] ;
232
218
_internalFetchControllers : any ;
@@ -248,8 +234,4 @@ export interface Router {
248
234
dispose ( ) : void ;
249
235
}
250
236
251
- export type CreateRouterFunction = (
252
- routes : RouteObject [ ] ,
253
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
254
- opts ?: any ,
255
- ) => Router ;
237
+ export type CreateRouterFunction = ( routes : RouteObject [ ] , opts ?: any ) => Router ;
0 commit comments