1+ // Disabling `no-explicit-any` for the whole file as `any` has became common requirement.
2+ /* eslint-disable @typescript-eslint/no-explicit-any */
13import { Transaction , TransactionContext } from '@sentry/types' ;
24
3- export type Action = 'PUSH' | 'REPLACE' | 'POP' ;
5+ export enum Action {
6+ Pop = 'POP' ,
7+ Push = 'PUSH' ,
8+ Replace = 'REPLACE' ,
9+ }
410
511export type Location = {
612 pathname : string ;
713 action ?: Action ;
8- // eslint-disable-next-line @typescript-eslint/no-explicit-any
914} & Record < string , any > ;
1015
1116export type ReactRouterInstrumentation = < T extends Transaction > (
@@ -19,15 +24,15 @@ export interface NonIndexRouteObject {
1924 caseSensitive ?: boolean ;
2025 children ?: RouteObject [ ] ;
2126 element ?: React . ReactNode | null ;
22- index ?: false ;
27+ index ?: any ;
2328 path ?: string ;
2429}
2530
2631export interface IndexRouteObject {
2732 caseSensitive ?: boolean ;
2833 children ?: undefined ;
2934 element ?: React . ReactNode | null ;
30- index : true ;
35+ index : any ;
3136 path ?: string ;
3237}
3338
@@ -69,9 +74,7 @@ export type UseNavigationType = () => Action;
6974// For both of these types, use `any` instead of `RouteObject[]` or `RouteMatch[]`.
7075// Have to do this so we maintain backwards compatability between
7176// react-router > 6.0.0 and >= 6.4.2.
72- // eslint-disable-next-line @typescript-eslint/no-explicit-any
7377export type RouteObjectArrayAlias = any ;
74- // eslint-disable-next-line @typescript-eslint/no-explicit-any
7578export type RouteMatchAlias = any ;
7679export type CreateRoutesFromChildren = ( children : JSX . Element [ ] ) => RouteObjectArrayAlias ;
7780export type MatchRoutes = ( routes : RouteObjectArrayAlias , location : Location ) => RouteMatchAlias [ ] | null ;
@@ -104,15 +107,9 @@ declare type AgnosticBaseRouteObject = {
104107 handle ?: any ;
105108} ;
106109
107- export declare type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
108- children ?: undefined ;
109- index : true ;
110- } ;
110+ export declare type AgnosticIndexRouteObject = AgnosticBaseRouteObject & Record < string , any > ;
111111
112- export declare type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
113- children ?: AgnosticRouteObject [ ] ;
114- index ?: false ;
115- } ;
112+ export declare type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & Record < string , any > ;
116113
117114export declare type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
118115 id : string ;
@@ -183,50 +180,39 @@ declare type SubmissionNavigateOptions = {
183180} ;
184181
185182export interface RouterInit {
186- basename ? : string ;
183+ basename : string ;
187184 routes : AgnosticRouteObject [ ] ;
188185 history : History ;
189186 hydrationData ?: HydrationState ;
190187}
191188
192189export 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 ;
217193} ;
218194
219195export type Navigation = NavigationStates [ keyof NavigationStates ] ;
220196
197+ export type RouteData = any ;
198+ export type Fetcher = any ;
199+
221200export interface RouterState {
222201 historyAction : Action ;
223- location : Location ;
202+ location : any ;
224203 matches : AgnosticDataRouteMatch [ ] ;
225204 initialized : boolean ;
226205 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 > ;
227213}
228214export interface Router {
229- basename : string ;
215+ basename : string | undefined ;
230216 state : RouterState ;
231217 routes : AgnosticDataRouteObject [ ] ;
232218 _internalFetchControllers : any ;
@@ -248,8 +234,4 @@ export interface Router {
248234 dispose ( ) : void ;
249235}
250236
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