Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/router-unused-imports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@tanstack/create': patch
---

Drop unused React Query imports from the generated React `router.tsx`. The
`tanstack-query` branch imported `ReactNode`, `QueryClient` and the
`TanstackQueryProvider` default export whenever the add-on was enabled, but
`ReactNode` and `TanstackQueryProvider` are only referenced inside the tRPC
`Wrap` block and `QueryClient` was never referenced at all. Generated projects
set `noUnusedLocals: true`, so a fresh scaffold shipped code that violates its
own tsconfig. The two tRPC-only imports are now gated behind
`addOnEnabled.tRPC` and the `QueryClient` import is removed.
12 changes: 12 additions & 0 deletions .changeset/trpc-dead-imports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@tanstack/create': patch
---

Drop two dead imports from the generated tRPC integration. `api.trpc.$.tsx`
imported `createServerFileRoute` from `@tanstack/react-start/server`, but the
route was already migrated to `createFileRoute(...)({ server: { handlers } })`
and that symbol is no longer exported, so the leftover import was both unused
and unresolvable. The tRPC branch of `root-provider.tsx` imported
`QueryClientProvider`, which it never renders —
`setupRouterSsrQueryIntegration` supplies the query client. Generated projects
set `noUnusedLocals: true`, so both showed up as errors in a fresh scaffold.
Comment on lines +9 to +12

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the query-client description.

getContext() creates the QueryClient; setupRouterSsrQueryIntegration receives that existing client to register SSR query integration. Please adjust this wording so the changeset does not misstate the responsibility of the integration.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.changeset/trpc-dead-imports.md around lines 9 - 12, Update the query-client
description in the changeset so it states that getContext() creates the
QueryClient and setupRouterSsrQueryIntegration receives that existing client to
register SSR query integration, rather than implying the integration supplies or
creates the client.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { createServerFileRoute } from '@tanstack/react-start/server'
import { fetchRequestHandler } from '@trpc/server/adapters/fetch'
import { trpcRouter } from '#/integrations/trpc/router'
import { createFileRoute } from '@tanstack/react-router'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% if (addOnEnabled.tRPC) { %>
import type { ReactNode } from 'react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { QueryClient } from '@tanstack/react-query'
import superjson from "superjson";
import { createTRPCClient, httpBatchStreamLink } from "@trpc/client";
import { createTRPCOptionsProxy } from "@trpc/tanstack-react-query";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { createRouter as createTanStackRouter } from '@tanstack/react-router'
import { routeTree } from './routeTree.gen'
<% if (addOnEnabled['tanstack-query']) { %>
import type { ReactNode } from 'react'
import { QueryClient } from '@tanstack/react-query'
<% if (addOnEnabled['tanstack-query']) { %><% if (addOnEnabled.tRPC) { %>
import type { ReactNode } from 'react'<% } %>
import { setupRouterSsrQueryIntegration } from "@tanstack/react-router-ssr-query";
import TanstackQueryProvider, { getContext } from './integrations/tanstack-query/root-provider'
import <% if (addOnEnabled.tRPC) { %>TanstackQueryProvider, <% } %>{ getContext } from './integrations/tanstack-query/root-provider'
<% } %>

export function getRouter() {
Expand Down