TanStack / TanStack/router

Can't use ValidateLinkOptions inside createFileRoute

Open
#5,906 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
15.1k
Forks
1.9k
Avg merge
1d 20h
Merged PRs (30d)
143

Description

Which project does this relate to?

Router

Describe the bug

When trying to use the type ValidateLinkOptions or similar (like LinkProps) inside the loader of createFileRoute, I get the error

'loader' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.

This seems like a regression, because it worked fine in v1.130.12.

Your Example Website or App

https://stackblitz.com/edit/github-mbsacxwx?file=src%2Froutes%2Findex.tsx

Steps to Reproduce the Bug or Issue

Return something typed as ValidateLinkOptions inside a loader. You must have a route that accepts parameters, like /user/$userId.

Expected behavior

This shouldn't happen, as the return type of a loader shouldn't be related to the route names.

Screenshots or Videos

No response

Platform
  • Router / Start Version: 1.136.14
  • OS: Linux
  • Browser: N/A
  • Browser Version: N/A
  • Bundler: rolldown-vite
  • Bundler Version: 7.2.5
Additional context

I using this to declare breadcrumbs, maybe this particular problem can be solved in another way

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the StackBlitz reproduction in src/routes/index.tsx and the createFileRoute loader using ValidateLinkOptions or LinkProps. Compare behavior between v1.130.12 and v1.136.14, then trace the route-parameter-dependent type relationship. Done when the reproduction no longer reports the implicit-any error for a loader returning a value typed with these link options.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.