Skip to content

Commit 797acd3

Browse files
authored
fix: Type errors in Router declaration file (#95)
* fix: Type errors in declaration files * chore: Formatting
1 parent fcd0328 commit 797acd3

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

jsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"noEmit": true,
77
"allowJs": true,
88
"checkJs": true,
9+
"skipLibCheck": false,
910
"jsx": "react",
1011
"jsxFactory": "h",
1112
"jsxFragmentFactory": "Fragment",

src/internal.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Component } from 'preact';
2+
13
export interface AugmentedComponent extends Component<any, any> {
24
__v: VNode;
35
__c: (error: Promise<void>, suspendingVNode: VNode) => void;

src/router.d.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AnyComponent, ComponentChildren, Context, FunctionComponent, VNode } from 'preact';
1+
import { AnyComponent, ComponentChildren, Context, VNode } from 'preact';
22

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

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

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+
1025
/**
1126
* Check if a URL path matches against a URL path pattern.
1227
*
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
1429
* @param url - URL path (e.g. /user/12345)
1530
* @param route - URL pattern (e.g. /user/:id)
1631
*/
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
3033

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

0 commit comments

Comments
 (0)