#How to create a typing for Link "to" ?

3 messages · Page 1 of 1 (latest)

reef barn
#

Hello, so example I have an array of string that is not a correct link, when i use it to loop over a <Link> it's just works. But, it shouldn't right? I want to add typing to my array, how can i do this?
thanks

jolly rain
#

Use this type FileRouteTypes["to"]

#
import type { FileRouteTypes } from "@/routeTree.gen";

const pages: Array<{
  name: string;
  Icon: LucideIcon;
  to: FileRouteTypes["to"];
}> = [
  { name: "Dashboard", Icon: LayoutDashboard, to: "/" },
  { name: "Loans", Icon: Banknote, to: "/loans" },
  { name: "Customers", Icon: Users, to: "/customers" },
];