Skip to content

Commit bcbc031

Browse files
feat: Switch routable props type over to an xor (#50)
* 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]>
1 parent d25dd07 commit bcbc031

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/router.d.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,11 @@ interface RouteHook {
2929
}
3030
export const useRoute: () => RouteHook;
3131

32-
interface RoutableProps {
33-
path?: string;
34-
default?: boolean;
35-
}
32+
type RoutableProps =
33+
| { path: string; default?: false; }
34+
| { path?: never; default: true; }
3635

37-
export interface RouteProps<Props> extends RoutableProps {
38-
component: AnyComponent<Props>;
39-
}
36+
export type RouteProps<Props> = RoutableProps & { component: AnyComponent<Props> };
4037

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

0 commit comments

Comments
 (0)