Skip to content

Commit

Permalink
Make useHref return a string with string param
Browse files Browse the repository at this point in the history
This avoids the need to handle an undefined value when the destination
parameter is known to be a string.
  • Loading branch information
sugar700 committed Jan 3, 2025
1 parent 1c9eb8e commit b93c0f9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const useResolvedPath = (path: () => string) => {
return createMemo(() => route.resolvePath(path()));
};

export const useHref = (to: () => string | undefined) => {
export const useHref = <T extends string | undefined>(to: () => T): string | T => {
const router = useRouter();
return createMemo(() => {
const to_ = to();
Expand Down

0 comments on commit b93c0f9

Please sign in to comment.