Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"noEmit": true,
"allowJs": true,
"checkJs": true,
"skipLibCheck": false,
"jsx": "react",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment",
Expand Down
2 changes: 2 additions & 0 deletions src/internal.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Component } from 'preact';

export interface AugmentedComponent extends Component<any, any> {
__v: VNode;
__c: (error: Promise<void>, suspendingVNode: VNode) => void;
Expand Down
33 changes: 18 additions & 15 deletions src/router.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnyComponent, ComponentChildren, Context, FunctionComponent, VNode } from 'preact';
import { AnyComponent, ComponentChildren, Context, VNode } from 'preact';

export const LocationProvider: {
(props: { scope?: string | RegExp; children?: ComponentChildren; }): VNode;
Expand All @@ -7,26 +7,29 @@ export const LocationProvider: {

type NestedArray<T> = Array<T | NestedArray<T>>;

interface KnownProps {
path: string;
query: Record<string, string>;
params: Record<string, string>;
default?: boolean;
rest?: string;
component?: AnyComponent;
}

interface ArbitraryProps {
[prop: string]: any;
}

type MatchProps = KnownProps & ArbitraryProps;

/**
* Check if a URL path matches against a URL path pattern.
*
* Warning: This is an internal API exported only for testing purpose. API could change in future.
* Warning: This is largely an internal API, it may change in the future
* @param url - URL path (e.g. /user/12345)
* @param route - URL pattern (e.g. /user/:id)
*/
export function exec(url: string, route: string, matches?: {
params: {
[param: string]: string;
};
rest?: string;
[props: string]: string;
}): {
params: {
[param: string]: string;
},
rest?: string;
[propsOrParam: string]: string;
}
export function exec(url: string, route: string, matches?: MatchProps): MatchProps

export function Router(props: {
onRouteChange?: (url: string) => void;
Expand Down