Skip to content

Commit

Permalink
feat: Switch routable props type over to an xor (#50)
Browse files Browse the repository at this point in the history
* feat: Switch routable props over to an xor to improve typing

* refactor: Improve type

Co-authored-by: Munawwar <[email protected]>

---------

Co-authored-by: Munawwar <[email protected]>
  • Loading branch information
rschristian and Munawwar authored Nov 5, 2024
1 parent d25dd07 commit bcbc031
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/router.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@ interface RouteHook {
}
export const useRoute: () => RouteHook;

interface RoutableProps {
path?: string;
default?: boolean;
}
type RoutableProps =
| { path: string; default?: false; }
| { path?: never; default: true; }

export interface RouteProps<Props> extends RoutableProps {
component: AnyComponent<Props>;
}
export type RouteProps<Props> = RoutableProps & { component: AnyComponent<Props> };

export function Route<Props>(props: RouteProps<Props> & Partial<Props>): VNode;

Expand Down

0 comments on commit bcbc031

Please sign in to comment.