Using beforeLoad causes typescript error in addChildren? #833
Unanswered
blitzbohne
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
hi everyone,
First: Great project though its sometimes hard to grasp your mind around a fully typesafe router :D
So here's an issue I am having and hopefully someone could point me to where I might have made some mistakes.
I am having a simple structure like this:
`const crmRouteRoot = new Route({
getParentRoute: () => appRoute,
path: '/crm',
component: Crm,
})
const crmCustomersRoute = new Route({
getParentRoute: () => crmRouteRoot,
path: '/contacts/customers',
component: Contacts(ContactType.Customer),
})
const crmIndexRoute = new Route({
getParentRoute: () => crmRouteRoot,
path: '/',
component: Root,
})
export const crmRoute = crmRouteRoot.addChildren([
crmIndexRoute,
crmCustomersRoute,
])`
This works just fine.
However as soon as I use beforeLoad on the child route:
`
const crmRouteRoot = new Route({
getParentRoute: () => appRoute,
path: '/crm',
component: Crm,
})
const crmCustomersRoute = new Route({
getParentRoute: () => crmRouteRoot,
path: '/contacts/customers',
component: Contacts(ContactType.Customer),
})
const crmIndexRoute = new Route({
getParentRoute: () => crmRouteRoot,
path: '/',
component: Root,
beforeLoad: async () => {
throw redirect({
replace: true,
to: crmCustomersRoute.fullPath
})
},
})
export const crmRoute = crmRouteRoot.addChildren([
crmIndexRoute,
crmCustomersRoute,
])
`
I am getting an error on it when being added via addChildren which says:
Type 'Route<Route<RootRoute<{}, RouteContext, {}, unknown>, "/crm", "/crm", string, "/crm", {}, {}, {}, {}, RouteContext, {}, AnyContext, unknown, unknown, AnyRoute>, ... 13 more ..., AnyRoute>' is not assignable to type 'AnyRoute'. Types of property 'options' are incompatible. Type 'RouteOptions<Route<RootRoute<{}, RouteContext, {}, unknown>, "/crm", "/crm", string, "/crm", {}, {}, {}, {}, RouteContext, {}, AnyContext, unknown, unknown, AnyRoute>, ... 8 more ..., unknown>' is not assignable to type 'RouteOptions<any, any, any, any, any, any, any, any, any, any>'. Type '{ path: "/"; } & { getParentRoute: () => Route<RootRoute<{}, RouteContext, {}, unknown>, "/crm", "/crm", string, "/crm", {}, {}, {}, {}, RouteContext, ... 4 more ..., AnyRoute>; validateSearch?: SearchSchemaValidator<...> | undefined; shouldReload?: boolean | ... 1 more ... | undefined; } & ... 4 more ... & { ...; }' is not assignable to type 'RouteOptions<any, any, any, any, any, any, any, any, any, any>'. Type '{ path: "/"; } & { getParentRoute: () => Route<RootRoute<{}, RouteContext, {}, unknown>, "/crm", "/crm", string, "/crm", {}, {}, {}, {}, RouteContext, ... 4 more ..., AnyRoute>; validateSearch?: SearchSchemaValidator<...> | undefined; shouldReload?: boolean | ... 1 more ... | undefined; } & ... 4 more ... & { ...; }' is not assignable to type '{ path: any; } & { getParentRoute: () => any; validateSearch?: SearchSchemaValidator<any> | undefined; shouldReload?: boolean | ((match: LoaderFnContext<any, any, any, any>) => any) | undefined; } & ... 4 more ... & { ...; }'. Type '{ path: "/"; } & { getParentRoute: () => Route<RootRoute<{}, RouteContext, {}, unknown>, "/crm", "/crm", string, "/crm", {}, {}, {}, {}, RouteContext, ... 4 more ..., AnyRoute>; validateSearch?: SearchSchemaValidator<...> | undefined; shouldReload?: boolean | ... 1 more ... | undefined; } & ... 4 more ... & { ...; }' is not assignable to type '{ getParentRoute: () => any; validateSearch?: SearchSchemaValidator<any> | undefined; shouldReload?: boolean | ((match: LoaderFnContext<any, any, any, any>) => any) | undefined; }'. Types of property 'shouldReload' are incompatible. Type 'boolean | ((match: LoaderFnContext<{}, {}, never, never>) => any) | undefined' is not assignable to type 'boolean | ((match: LoaderFnContext<any, any, any, any>) => any) | undefined'. Type '(match: LoaderFnContext<{}, {}, never, never>) => any' is not assignable to type 'boolean | ((match: LoaderFnContext<any, any, any, any>) => any) | undefined'. Type '(match: LoaderFnContext<{}, {}, never, never>) => any' is not assignable to type '(match: LoaderFnContext<any, any, any, any>) => any'. Types of parameters 'match' and 'match' are incompatible. Type 'LoaderFnContext<any, any, any, any>' is not assignable to type 'LoaderFnContext<{}, {}, never, never>'. Types of property 'context' are incompatible. Type 'any' is not assignable to type 'never'.ts(2322)
Beta Was this translation helpful? Give feedback.
All reactions