Skip to content

Commit 0c8256f

Browse files
authored
Merge pull request #9 from notnotsamuel/fix-typescript-declarations
fix(types): correct declaration files and package.json exports
2 parents 85623c9 + 27f9878 commit 0c8256f

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"src/lib"
1414
],
1515
"exports": {
16+
"types": "./src/lib/index.d.ts",
1617
"svelte": "./src/lib/index.js",
1718
"import": "./dist/svelte-tiny-router.es.js",
1819
"require": "./dist/svelte-tiny-router.umd.js"
@@ -45,4 +46,4 @@
4546
"url": "https://github.com/notnotsamuel/svelte-tiny-router/issues"
4647
},
4748
"homepage": "https://github.com/notnotsamuel/svelte-tiny-router#readme"
48-
}
49+
}

src/lib/context.d.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { SvelteComponent } from 'svelte';
2-
import type { NavigationGuard } from './Router.svelte.d.ts'; // Import for beforeEach type
2+
import type { NavigationGuard } from './Router.svelte';
33

44
export interface RouterContext {
55
base: string; // Base path of the current router instance
@@ -14,6 +14,4 @@ export interface RouterContext {
1414
getQueryParam: (key: string) => string | undefined;
1515
hasQueryParam: (key: string) => boolean;
1616
removeQueryParams: (keys: string[]) => void;
17-
}
18-
19-
export function useTinyRouter(): RouterContext;
17+
}

src/lib/index.d.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
export { navigate } from './navigate.js';
2-
export { useTinyRouter, type RouterContext } from './context.js';
3-
export { default as Route, type RouteProps } from './Route.svelte';
1+
import type { RouterContext } from './context';
2+
43
export { default as Router, type RouterProps } from './Router.svelte';
4+
export { default as Route, type RouteProps } from './Route.svelte';
5+
export { navigate } from './navigate';
6+
7+
/**
8+
* retrieve the router context
9+
*/
10+
export function useTinyRouter(): RouterContext;
11+
12+
// Export the context type for users
13+
export type { RouterContext };

0 commit comments

Comments
 (0)