From 59a86cd8a75feee09bb9a52edd9474994166a5eb Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Fri, 6 Jun 2025 15:49:00 -0500 Subject: [PATCH 1/2] fix: Type errors in declaration files --- jsconfig.json | 1 + src/internal.d.ts | 2 ++ src/router.d.ts | 33 ++++++++++++++++++--------------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/jsconfig.json b/jsconfig.json index 60c72b4..aeea0d1 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -6,6 +6,7 @@ "noEmit": true, "allowJs": true, "checkJs": true, + "skipLibCheck": false, "jsx": "react", "jsxFactory": "h", "jsxFragmentFactory": "Fragment", diff --git a/src/internal.d.ts b/src/internal.d.ts index efcd0f0..eb1ca3a 100644 --- a/src/internal.d.ts +++ b/src/internal.d.ts @@ -1,3 +1,5 @@ +import { Component } from 'preact'; + export interface AugmentedComponent extends Component { __v: VNode; __c: (error: Promise, suspendingVNode: VNode) => void; diff --git a/src/router.d.ts b/src/router.d.ts index 8cb4619..ed0d2bb 100644 --- a/src/router.d.ts +++ b/src/router.d.ts @@ -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; @@ -7,26 +7,29 @@ export const LocationProvider: { type NestedArray = Array>; +interface KnownProps { + path: string; + query: Record; + params: Record; + 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; From 0a6fba3841c6e8a398d2ea57b21e7150c47d2b6c Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Fri, 6 Jun 2025 15:50:32 -0500 Subject: [PATCH 2/2] chore: Formatting --- jsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsconfig.json b/jsconfig.json index aeea0d1..8956b42 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -6,7 +6,7 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "skipLibCheck": false, + "skipLibCheck": false, "jsx": "react", "jsxFactory": "h", "jsxFragmentFactory": "Fragment",