Skip to content

Type Error for routes #555

Description

Describe the bug

I have working routes when using my app that work perfectly, however when using or , the routes do not exist.

Type '{ children: Element[]; to: "/app"; className: string; }' is missing the following properties
from type 'CheckPathError<RoutesInfo<RootRoute<{}, RouteContext, RouterContext>>, "/app">': Error,
'Valid Route Paths'

Your Example Website or App

xxx

Steps to Reproduce the Bug or Issue

routes.tsx

import { Outlet, RootRoute, Route } from "@tanstack/react-router";
import IndexPage from "@/pages";
export const rootRoute = new RootRoute({
  component: Outlet,
});
const appRoute = new Route({
  path: "/app",
  getParentRoute: () => rootRoute,
});
const appIndexRoute = new Route({
  path: "/",
  component: () => (
    <Layout>
      <IndexPage />
    </Layout>
  ),
  getParentRoute: () => appRoute,
});
rootRoute.addChildren([
  appRoute.addChildren([
    appIndexRoute,
  ]),
]);

router.tsx

import React from "react";
import { ReactRouter, RouterProvider } from "@tanstack/react-router";
import { rootRoute } from "./_routes";
const router = new ReactRouter({
  routeTree: rootRoute,
});
export const Router = () => <RouterProvider router={router} />;
declare module "@tanstack/react-router" {
  interface Register {
    router: typeof router;
  }
}
<Link to={"/app"}>
  Go to app
</Link>
Type '{ children: Element[]; to: "/app"; className: string; }' is missing the following properties from 
type 'CheckPathError<RoutesInfo<RootRoute<{}, RouteContext, RouterContext>>, "/app">': Error, 'Valid Route Paths'

Expected behavior

As a user I expected there not to be an issue with typing.

Screenshots or Videos

image

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions