Steve A
Steve A•4w ago

Type checking with tanstack router

I've been developing a project with tanstack router, deno, and hono. It's working fine; my IDE is happy, the app runs, and I can run deno lint and deno format without issues. However, when I run deno check, I always get errors like this:
TS2345 [ERROR]: Argument of type '"/visualize"' is not assignable to parameter of type 'undefined'.
export const Route = createFileRoute("/visualize")({
~~~~~~~~~~~~
at file:///Users/steve.adams/Work/DarwinKit/src/routes/visualize.tsx:28:38
TS2345 [ERROR]: Argument of type '"/visualize"' is not assignable to parameter of type 'undefined'.
export const Route = createFileRoute("/visualize")({
~~~~~~~~~~~~
at file:///Users/steve.adams/Work/DarwinKit/src/routes/visualize.tsx:28:38
I'm hoping someone might be able to clue me in to why deno's type checker wouldn't be aware of the tanstack router types. The tanstack router model is declared in the generated route tree, along with in my app's entry point:
import { routeTree } from "./routeTree.gen.ts";

const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 1000 * 60 * 5,
retry: 1,
},
},
});

const router = createRouter({
routeTree,
context: { queryClient },
defaultPreload: "intent",
});

declare module "@tanstack/react-router" {
interface Register {
router: typeof router;
}
}
import { routeTree } from "./routeTree.gen.ts";

const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 1000 * 60 * 5,
retry: 1,
},
},
});

const router = createRouter({
routeTree,
context: { queryClient },
defaultPreload: "intent",
});

declare module "@tanstack/react-router" {
interface Register {
router: typeof router;
}
}
Thanks for any insight here! I'm really stumped.
4 Replies
marvinh.
marvinh.•4w ago
Can you file an issue for that https://github.com/denoland/deno/issues ?
GitHub
denoland/deno
A modern runtime for JavaScript and TypeScript. Contribute to denoland/deno development by creating an account on GitHub.
Steve A
Steve AOP•4w ago
Yes! I'll make a repro and throw it up. This is driving me nuts 😃 Is there a specific, preferred way to make repros? I could make a new repository, but perhaps there's a playground or sandboxing system running live that maintainers prefer?
marvinh.
marvinh.•3w ago
A GitHub repository is fine as a reproduction
Steve A
Steve AOP•3w ago
It was a bug! If anyone else searches for this, the issue chain started here: https://github.com/denoland/deno/issues/30433 And there is a PR here: https://github.com/denoland/deno_graph/pull/604 Really stoked to run into an issue and see such a quick response. It gives me a lot of confidence in the runtime
GitHub
Deno check doesn't find all ambient types when using tanstack route...
Version: Deno 2.4.4 Although I'm referencing 2.4.4 as the version, I've experienced this since 2.3.x at least. Here is a reproduction: https://github.com/steveadams/tanstackrouter-deno-repr...
GitHub
feat: detect module augmentations as dependencies by nayeemrmn · P...
Wil fix .. denoland/deno#30444. Uniquely to this import kind: If the specifier doesn't resolve to some types module being augmented, it won't count as a dependency.

Did you find this page helpful?