TanStackT
TanStack10mo ago
4 replies
nursing-lime

How to props typesafety for a LinkCard component?

Basically I want my <LinkCard> component to error the same way <Link> from @tanstack/router if you fail to give it a to="" prop
function LinkCard({ className, ...props }: LinkComponentProps) {
  return (
    <Link
      data-slot="card"
      className={cn(
        "bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
        className,
      )}
      {...props}
    />
  );
}

This works, but it doesn't have the same level of typesafety as the native <Link> tag.
image.png
image.png
Was this page helpful?