1
- import { AnyComponent , ComponentChildren , Context , FunctionComponent , VNode } from 'preact' ;
1
+ import { AnyComponent , ComponentChildren , Context , VNode } from 'preact' ;
2
2
3
3
export const LocationProvider : {
4
4
( props : { scope ?: string | RegExp ; children ?: ComponentChildren ; } ) : VNode ;
@@ -7,26 +7,29 @@ export const LocationProvider: {
7
7
8
8
type NestedArray < T > = Array < T | NestedArray < T > > ;
9
9
10
+ interface KnownProps {
11
+ path : string ;
12
+ query : Record < string , string > ;
13
+ params : Record < string , string > ;
14
+ default ?: boolean ;
15
+ rest ?: string ;
16
+ component ?: AnyComponent ;
17
+ }
18
+
19
+ interface ArbitraryProps {
20
+ [ prop : string ] : any ;
21
+ }
22
+
23
+ type MatchProps = KnownProps & ArbitraryProps ;
24
+
10
25
/**
11
26
* Check if a URL path matches against a URL path pattern.
12
27
*
13
- * Warning: This is an internal API exported only for testing purpose. API could change in future.
28
+ * Warning: This is largely an internal API, it may change in the future
14
29
* @param url - URL path (e.g. /user/12345)
15
30
* @param route - URL pattern (e.g. /user/:id)
16
31
*/
17
- export function exec ( url : string , route : string , matches ?: {
18
- params : {
19
- [ param : string ] : string ;
20
- } ;
21
- rest ?: string ;
22
- [ props : string ] : string ;
23
- } ) : {
24
- params : {
25
- [ param : string ] : string ;
26
- } ,
27
- rest ?: string ;
28
- [ propsOrParam : string ] : string ;
29
- }
32
+ export function exec ( url : string , route : string , matches ?: MatchProps ) : MatchProps
30
33
31
34
export function Router ( props : {
32
35
onRouteChange ?: ( url : string ) => void ;
0 commit comments