@@ -44,6 +44,11 @@ export type Query = {
44
44
[ key : string ] : string ;
45
45
} ;
46
46
47
+ export type MatchedInvariantRoute = {
48
+ route : InvariantRoute ;
49
+ match : Match ;
50
+ } ;
51
+
47
52
export type MatchedRoute = {
48
53
route : Route ;
49
54
match : Match ;
@@ -106,25 +111,43 @@ export type RouterContext = {
106
111
query : Query ;
107
112
} ;
108
113
109
- export type Route = {
114
+ /**
115
+ * Invariant route
116
+ *
117
+ * Base type for route, which doesn't contain implementation details
118
+ */
119
+ export type InvariantRoute = {
110
120
path : string ;
111
121
exact ?: boolean ;
112
122
113
- /** The component to render on match, typed explicitly */
114
- component : ComponentType < RouteContext > ;
115
-
116
- /** If present, must return true to include the route. */
117
- enabled ?: ( ) => boolean ;
118
-
119
- /** Signals that this is a redirect route, we need to handle these in a special way. */
120
- isRedirect ?: boolean ;
121
-
122
123
/** Used to prevent transitions between app groups */
123
124
group ?: string ;
124
125
125
126
/** Unique name for the route */
126
127
name : string ;
127
128
129
+ /**
130
+ * Query string matching. Each query param must match for the route to match.
131
+ *
132
+ * A query param can take the following shapes:
133
+ * * query name only: 'foo' - matches if query name 'foo' is present
134
+ * * query name matching value: 'foo=bar' - matches if query name 'foo' equals
135
+ * 'bar' exactly
136
+ * * query name matching regex: 'foo=(bar.+) - matches if query name 'foo' equals
137
+ * regex '^(bar.+)$'. Note you must escape backslashes and wrap regex in parentheses.
138
+ * * query name NOT matching value: 'foo!=bar' - matches if query name 'foo' does
139
+ * not equal bar OR if query name 'foo' does not exist at all
140
+ */
141
+ query ?: string [ ] ;
142
+ } ;
143
+
144
+ export type Route = InvariantRoute & {
145
+ /** The component to render on match, typed explicitly */
146
+ component : ComponentType < RouteContext > ;
147
+
148
+ /** If present, must return true to include the route. */
149
+ enabled ?: ( ) => boolean ;
150
+
128
151
/**
129
152
* Triggered before leaving the route, can trigger full page reload if returns (or resolves) false.
130
153
* Defaults to true.
@@ -134,6 +157,7 @@ export type Route = {
134
157
nextRouteMatch : MatchedRoute ,
135
158
props : any
136
159
) => boolean | Promise < boolean > ;
160
+
137
161
/**
138
162
* Triggered before entering the route, can trigger full page reload if returns (or resolves) false.
139
163
* Defaults to true.
@@ -143,19 +167,7 @@ export type Route = {
143
167
nextRouteMatch : MatchedRoute ,
144
168
props : any
145
169
) => boolean | Promise < boolean > ;
146
- /**
147
- * Query string matching. Each query param must match for the route to match.
148
- *
149
- * A query param can take the following shapes:
150
- * * query name only: 'foo' - matches if query name 'foo' is present
151
- * * query name matching value: 'foo=bar' - matches if query name 'foo' equals
152
- * 'bar' exactly
153
- * * query name matching regex: 'foo=(bar.+) - matches if query name 'foo' equals
154
- * regex '^(bar.+)$'. Note you must escape backslashes and wrap regex in parentheses.
155
- * * query name NOT matching value: 'foo!=bar' - matches if query name 'foo' does
156
- * not equal bar OR if query name 'foo' does not exist at all
157
- */
158
- query ?: string [ ] ;
170
+
159
171
/**
160
172
* The resources for the route
161
173
*/
@@ -164,6 +176,7 @@ export type Route = {
164
176
165
177
export type HistoryAction = 'PUSH' | 'REPLACE' | 'POP' | '' ;
166
178
179
+ export type InvariantRoutes = InvariantRoute [ ] ;
167
180
export type Routes = Route [ ] ;
168
181
169
182
export type NavigationType = 'container' | 'product' ;
0 commit comments