Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ type HTMLAnchorProps = DetailedHTMLProps<
export interface RegisterLink {}

export type RegisteredLinkProps = RegisterLink extends { Link: infer Link }
?
| Omit<UnpackProps<Link>, "children">
| (Omit<HTMLAnchorProps, "children" | "href"> & {
href: string;
})
? LinkPropsWithoutChildren<UnpackProps<Link>>
: RegisterLink extends { LinkProps: infer LinkProps }
? LinkPropsWithoutChildren<LinkProps>
: Omit<HTMLAnchorProps, "children">;

type LinkPropsWithoutChildren<LinkProps> =
| Omit<LinkProps, "children">
| (Omit<HTMLAnchorProps, "children" | "href"> & {
href: string;
});

let Link: React.ComponentType<RegisteredLinkProps & { children: ReactNode }> = props => {
const { href, ...rest } = props as { to?: string; href?: string };

Expand Down