T
TanStack2mo ago
absent-sapphire

Type 'Promise<void>' is not assignable to type 'never'

getting these weird errors after updating all start/tanstack packages
Type '() => Promise<{ readonly dehydratedState: DehydratedState; } | undefined>' is not assignable to type '((ctx: LoaderFnContext<Register, any, "__root__", {}, {}, MyRouterContext, AnyContext, AnyContext, unknown, undefined>) => Promise<...>) | ((ctx: LoaderFnContext<...>) => Promise<...>) | undefined'.
Type '() => Promise<{ readonly dehydratedState: DehydratedState; } | undefined>' is not assignable to type '(ctx: LoaderFnContext<Register, any, "__root__", {}, {}, MyRouterContext, AnyContext, AnyContext, unknown, undefined>) => Promise<...>'.
Type 'Promise<{ readonly dehydratedState: DehydratedState; } | undefined>' is not assignable to type 'Promise<{ readonly dehydratedState: { mutations: { mutationKey?: readonly {}[] | undefined; state: { context: {}; data: {}; error: { name: string; message: string; stack?: string | undefined; cause?: {} | undefined; } | null; ... 5 more ...; submittedAt: number; }; meta?: { ...; } | undefined; scope?: { ...; } | und...'.
Type '{ readonly dehydratedState: DehydratedState; } | undefined' is not assignable to type '{ readonly dehydratedState: { mutations: { mutationKey?: readonly {}[] | undefined; state: { context: {}; data: {}; error: { name: string; message: string; stack?: string | undefined; cause?: {} | undefined; } | null; ... 5 more ...; submittedAt: number; }; meta?: { ...; } | undefined; scope?: { ...; } | undefined; ...'.
Type '{ readonly dehydratedState: DehydratedState; }' is not assignable to type '{ readonly dehydratedState: { mutations: { mutationKey?: readonly {}[] | undefined; state: { context: {}; data: {}; error: { name: string; message: string; stack?: string | undefined; cause?: {} | undefined; } | null; ... 5 more ...; submittedAt: number; }; meta?: { ...; } | undefined; scope?: { ...; } | undefined; ...'.
The types of 'dehydratedState.mutations' are incompatible between these types.
Type 'DehydratedMutation[]' is not assignable to type '{ mutationKey?: readonly {}[] | undefined; state: { context: {}; data: {}; error: { name: string; message: string; stack?: string | undefined; cause?: {} | undefined; } | null; failureCount: number; failureReason: { ...; } | null; isPaused: boolean; status: MutationStatus; variables: {}; submittedAt: number; }; meta...'.
Type 'DehydratedMutation' is not assignable to type '{ mutationKey?: readonly {}[] | undefined; state: { context: {}; data: {}; error: { name: string; message: string; stack?: string | undefined; cause?: {} | undefined; } | null; failureCount: number; failureReason: { ...; } | null; isPaused: boolean; status: MutationStatus; variables: {}; submittedAt: number; }; meta...'.
Types of property 'mutationKey' are incompatible.
Type 'readonly unknown[] | undefined' is not assignable to type 'readonly {}[] | undefined'.
Type 'readonly unknown[]' is not assignable to type 'readonly {}[]'.
Type 'unknown' is not assignable to type '{}'.ts(2322)
Type '() => Promise<{ readonly dehydratedState: DehydratedState; } | undefined>' is not assignable to type '((ctx: LoaderFnContext<Register, any, "__root__", {}, {}, MyRouterContext, AnyContext, AnyContext, unknown, undefined>) => Promise<...>) | ((ctx: LoaderFnContext<...>) => Promise<...>) | undefined'.
Type '() => Promise<{ readonly dehydratedState: DehydratedState; } | undefined>' is not assignable to type '(ctx: LoaderFnContext<Register, any, "__root__", {}, {}, MyRouterContext, AnyContext, AnyContext, unknown, undefined>) => Promise<...>'.
Type 'Promise<{ readonly dehydratedState: DehydratedState; } | undefined>' is not assignable to type 'Promise<{ readonly dehydratedState: { mutations: { mutationKey?: readonly {}[] | undefined; state: { context: {}; data: {}; error: { name: string; message: string; stack?: string | undefined; cause?: {} | undefined; } | null; ... 5 more ...; submittedAt: number; }; meta?: { ...; } | undefined; scope?: { ...; } | und...'.
Type '{ readonly dehydratedState: DehydratedState; } | undefined' is not assignable to type '{ readonly dehydratedState: { mutations: { mutationKey?: readonly {}[] | undefined; state: { context: {}; data: {}; error: { name: string; message: string; stack?: string | undefined; cause?: {} | undefined; } | null; ... 5 more ...; submittedAt: number; }; meta?: { ...; } | undefined; scope?: { ...; } | undefined; ...'.
Type '{ readonly dehydratedState: DehydratedState; }' is not assignable to type '{ readonly dehydratedState: { mutations: { mutationKey?: readonly {}[] | undefined; state: { context: {}; data: {}; error: { name: string; message: string; stack?: string | undefined; cause?: {} | undefined; } | null; ... 5 more ...; submittedAt: number; }; meta?: { ...; } | undefined; scope?: { ...; } | undefined; ...'.
The types of 'dehydratedState.mutations' are incompatible between these types.
Type 'DehydratedMutation[]' is not assignable to type '{ mutationKey?: readonly {}[] | undefined; state: { context: {}; data: {}; error: { name: string; message: string; stack?: string | undefined; cause?: {} | undefined; } | null; failureCount: number; failureReason: { ...; } | null; isPaused: boolean; status: MutationStatus; variables: {}; submittedAt: number; }; meta...'.
Type 'DehydratedMutation' is not assignable to type '{ mutationKey?: readonly {}[] | undefined; state: { context: {}; data: {}; error: { name: string; message: string; stack?: string | undefined; cause?: {} | undefined; } | null; failureCount: number; failureReason: { ...; } | null; isPaused: boolean; status: MutationStatus; variables: {}; submittedAt: number; }; meta...'.
Types of property 'mutationKey' are incompatible.
Type 'readonly unknown[] | undefined' is not assignable to type 'readonly {}[] | undefined'.
Type 'readonly unknown[]' is not assignable to type 'readonly {}[]'.
Type 'unknown' is not assignable to type '{}'.ts(2322)
export const Route = createRootRouteWithContext<MyRouterContext>()({
head: () => HEAD,
loader: async () => {
const session = await getSession();

if (session) {
const queryClient = getQueryClient();
await queryClient.prefetchQuery({
queryKey: ["session"],
queryFn: () => session,
});
const dehydratedState = dehydrate(queryClient);
return {
dehydratedState,
} as const;
}
},
shellComponent: RootDocument,
notFoundComponent: () => <NotFound />,
});
export const Route = createRootRouteWithContext<MyRouterContext>()({
head: () => HEAD,
loader: async () => {
const session = await getSession();

if (session) {
const queryClient = getQueryClient();
await queryClient.prefetchQuery({
queryKey: ["session"],
queryFn: () => session,
});
const dehydratedState = dehydrate(queryClient);
return {
dehydratedState,
} as const;
}
},
shellComponent: RootDocument,
notFoundComponent: () => <NotFound />,
});
24 Replies
absent-sapphire
absent-sapphireOP2mo ago
export const Route = createFileRoute("/chat-with/$group")({
head: //truncated...
loader: async ({ params }) => {
if (!(params.group in MODEL_GROUPS)) {
throw notFound({
routeId: "/new",
});
}
},
component: () => <ChatWithBranches isSharedView={false} />,
});
export const Route = createFileRoute("/chat-with/$group")({
head: //truncated...
loader: async ({ params }) => {
if (!(params.group in MODEL_GROUPS)) {
throw notFound({
routeId: "/new",
});
}
},
component: () => <ChatWithBranches isSharedView={false} />,
});
Type '({ params }: LoaderFnContext<Register, RootRoute<Register, undefined, MyRouterContext, AnyContext, AnyContext, {}, () => Promise<{ readonly dehydratedState: DehydratedState; } | undefined>, ... 4 more ..., undefined>, ... 7 more ..., undefined>) => Promise<...>' is not assignable to type '(ctx: LoaderFnContext<Register, RootRoute<Register, undefined, MyRouterContext, AnyContext, AnyContext, {}, () => Promise<{ readonly dehydratedState: DehydratedState; } | undefined>, ... 4 more ..., undefined>, ... 7 more ..., undefined>) => never'.
Type 'Promise<void>' is not assignable to type 'never'.ts(2322)
Type '({ params }: LoaderFnContext<Register, RootRoute<Register, undefined, MyRouterContext, AnyContext, AnyContext, {}, () => Promise<{ readonly dehydratedState: DehydratedState; } | undefined>, ... 4 more ..., undefined>, ... 7 more ..., undefined>) => Promise<...>' is not assignable to type '(ctx: LoaderFnContext<Register, RootRoute<Register, undefined, MyRouterContext, AnyContext, AnyContext, {}, () => Promise<{ readonly dehydratedState: DehydratedState; } | undefined>, ... 4 more ..., undefined>, ... 7 more ..., undefined>) => never'.
Type 'Promise<void>' is not assignable to type 'never'.ts(2322)
actually here's the whole chunk here with head because commenting out the head part fixes it...
export const Route = createFileRoute("/models/$modelId")({
head: ({ params }) => {
const model = SHARED_MODELS[params.modelId as keyof typeof SHARED_MODELS];

const baseUrl =
(typeof window !== "undefined" && window.location?.origin) ||
env_client?.VITE_APP_URL ||
"https://uncovr.app";
const canonicalUrl = `${baseUrl}/models/${params.modelId}`;

const title = model
? `Chat with ${model.metadata.title}`
: "Fast AI chat with 40+ models • uncovr";
const description = model
? `Chat with ${model.metadata.title} and 40+ top AI models, all in one place.`
: "Fast AI chat with 40+ models like ChatGPT, Gemini, Claude, and more all in one place.";

return {
meta: [
{ title },
{ name: "description", content: description },

// Open Graph
{ property: "og:title", content: title },
{ property: "og:description", content: description },
{ property: "og:url", content: canonicalUrl },
{ property: "og:type", content: "website" },

// Twitter
{ name: "twitter:title", content: title },
{ name: "twitter:description", content: description },
],
links: [{ rel: "canonical", href: canonicalUrl }],
scripts: [
{
type: "application/ld+json",
children: JSON.stringify({
"@context": "https://schema.org",
"@type": "WebPage",
url: canonicalUrl,
name: title,
description,
isPartOf: { "@type": "WebSite", name: "uncovr", url: baseUrl },
}),
},
],
};
},
loader: async ({ params }) => {
if (!(params.modelId in SHARED_MODELS)) {
throw notFound({
routeId: "/new",
});
}
},
component: () => <ChatWithBranches isSharedView={false} />,
});
export const Route = createFileRoute("/models/$modelId")({
head: ({ params }) => {
const model = SHARED_MODELS[params.modelId as keyof typeof SHARED_MODELS];

const baseUrl =
(typeof window !== "undefined" && window.location?.origin) ||
env_client?.VITE_APP_URL ||
"https://uncovr.app";
const canonicalUrl = `${baseUrl}/models/${params.modelId}`;

const title = model
? `Chat with ${model.metadata.title}`
: "Fast AI chat with 40+ models • uncovr";
const description = model
? `Chat with ${model.metadata.title} and 40+ top AI models, all in one place.`
: "Fast AI chat with 40+ models like ChatGPT, Gemini, Claude, and more all in one place.";

return {
meta: [
{ title },
{ name: "description", content: description },

// Open Graph
{ property: "og:title", content: title },
{ property: "og:description", content: description },
{ property: "og:url", content: canonicalUrl },
{ property: "og:type", content: "website" },

// Twitter
{ name: "twitter:title", content: title },
{ name: "twitter:description", content: description },
],
links: [{ rel: "canonical", href: canonicalUrl }],
scripts: [
{
type: "application/ld+json",
children: JSON.stringify({
"@context": "https://schema.org",
"@type": "WebPage",
url: canonicalUrl,
name: title,
description,
isPartOf: { "@type": "WebSite", name: "uncovr", url: baseUrl },
}),
},
],
};
},
loader: async ({ params }) => {
if (!(params.modelId in SHARED_MODELS)) {
throw notFound({
routeId: "/new",
});
}
},
component: () => <ChatWithBranches isSharedView={false} />,
});
manual-pink
manual-pink2mo ago
can you put this in one of our examples so we have a complete project we can just clone and debug?
absent-sapphire
absent-sapphireOP2mo ago
GitHub
GitHub - f1shy-dev/reproduction-issue-tanstack-start
Contribute to f1shy-dev/reproduction-issue-tanstack-start development by creating an account on GitHub.
absent-sapphire
absent-sapphireOP2mo ago
reproduced the first issue in src/routes/__root.tsx working on trying to get the second one reproduced
manual-pink
manual-pink2mo ago
ok so this type error occurs because you return something from loader that contains some unknown types which we prohibit, since this could mean it is not serializable at runtime however, you dont need all of this
manual-pink
manual-pink2mo ago
TanStack Query Integration | TanStack Router Docs
[!IMPORTANT] This integration automates SSR dehydration/hydration and streaming between TanStack Router and TanStack Query. If you haven't read the standard guide, start there. What you get Automatic...
absent-sapphire
absent-sapphireOP2mo ago
that resolves this one! but i'm not really sure how to reproduce this other one
Type '({ params }: LoaderFnContext<Register, RootRoute<Register, undefined, MyRouterContext, AnyContext, AnyContext, {}, ({ context }: LoaderFnContext<Register, ... 8 more ..., undefined>) => Promise<...>, ... 4 more ..., undefined>, ... 7 more ..., undefined>) => Promise<...>' is not assignable to type '(ctx: LoaderFnContext<Register, RootRoute<Register, undefined, MyRouterContext, AnyContext, AnyContext, {}, ({ context }: LoaderFnContext<Register, ... 8 more ..., undefined>) => Promise<...>, ... 4 more ..., undefined>, ... 7 more ..., undefined>) => never'.
Type 'Promise<void>' is not assignable to type 'never'.ts(2322)
Type '({ params }: LoaderFnContext<Register, RootRoute<Register, undefined, MyRouterContext, AnyContext, AnyContext, {}, ({ context }: LoaderFnContext<Register, ... 8 more ..., undefined>) => Promise<...>, ... 4 more ..., undefined>, ... 7 more ..., undefined>) => Promise<...>' is not assignable to type '(ctx: LoaderFnContext<Register, RootRoute<Register, undefined, MyRouterContext, AnyContext, AnyContext, {}, ({ context }: LoaderFnContext<Register, ... 8 more ..., undefined>) => Promise<...>, ... 4 more ..., undefined>, ... 7 more ..., undefined>) => never'.
Type 'Promise<void>' is not assignable to type 'never'.ts(2322)
manual-pink
manual-pink2mo ago
Ensure correct order of inference sensitive properties for createRo...
For the following functions, the property order of the passed in object matters due to type inference: createRoute createFileRoute createRootRoute createRootRouteWithContext The correct property order...
manual-pink
manual-pink2mo ago
so reorder, loader before head
absent-sapphire
absent-sapphireOP2mo ago
ok that worked that is such a random thing 😅 i didn't know there is an eslint plugin though, TIL! will add that... wait no i use biome
absent-sapphire
absent-sapphireOP2mo ago
No description
absent-sapphire
absent-sapphireOP2mo ago
thanks for the help!
manual-pink
manual-pink2mo ago
yes it's unfortunate that typescript works like this...
absent-sapphire
absent-sapphireOP2mo ago
actually i did have another quick question
manual-pink
manual-pink2mo ago
sure
absent-sapphire
absent-sapphireOP2mo ago
(finding the file, 1min) earlier i had a nitro.config.ts
export default defineNitroConfig({
routeRules: {
'/api/pql/static/**': { proxy: 'https://eu-assets.i.posthog.com/static/**' },
'/api/pql/**': { proxy: 'https://eu.i.posthog.com/**' },
'/api/pql/decide': { proxy: 'https://eu.i.posthog.com/decide' },
}
})
export default defineNitroConfig({
routeRules: {
'/api/pql/static/**': { proxy: 'https://eu-assets.i.posthog.com/static/**' },
'/api/pql/**': { proxy: 'https://eu.i.posthog.com/**' },
'/api/pql/decide': { proxy: 'https://eu.i.posthog.com/decide' },
}
})
now i'm using the cloudflare-vite plugin is there an easy way to setup rewrites like this now? or would i have to manually just set that up in something like server.tsx (or a file route)?
manual-pink
manual-pink2mo ago
not aware of any "easy config" here
manual-pink
manual-pink2mo ago
GitHub
cloudflare workers-sdk · Discussions
Explore the GitHub Discussions forum for cloudflare workers-sdk. Discuss code, ask questions & collaborate with the developer community.
manual-pink
manual-pink2mo ago
if there is a cloudflare specific way otherwise, yes you would need to configure those proxies manually we might add some utils later, but you would still need to employ them
absent-sapphire
absent-sapphireOP2mo ago
the cf worker will run on any non-assets route anyway right so i should be fine to just make an api route with a splat which does this
manual-pink
manual-pink2mo ago
yes an api route should work. or a request middleware there are a few options
absent-sapphire
absent-sapphireOP2mo ago
does server.handlers support like a *? like all http methods through one function
manual-pink
manual-pink2mo ago
yes ANY

Did you find this page helpful?