TanStackT
TanStack3mo ago
45 replies
safe-amethyst

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)


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 />,
});
Was this page helpful?