Route generation does not allow plain template literals anymore after 1.166.31
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
Code that worked in router-cli@1.166.30 and below
const routeVarOfferDefinition = `/offers` as const;
const routeApi = getRouteApi(
`/$locale/_main/(offers)${routeVarOfferDefinition}/$actionId/$tab`,
);
export const Route = createFileRoute(
`/$locale/_main/(offers)${routeVarOfferDefinition}/$actionId/$tab`,
)({
now in 1.166.31+ throws this error during route generation
Error: Error transforming route file /front/spa/src/routes/$locale/_main/(offers)/-offer/$actionId/$tab.tsx:
Error: expected route id to be a string literal or plain template literal in /$locale/_main/(offers)/offers/$actionId/$tab
We were relying heavily on semi dynamic URLs (we generate routeVarOfferDefinition like consts during prepare step before TanStack Router kicks in) and actually the error implies that it should work but does not.
I guess this PR is to blame
https://github.com/TanStack/router/pull/7167
Your Example Website or App
https://stackblitz.com/edit/github-t8vtvecd?file=src%2Froutes%2Fabout.tsx,package.json
Steps to Reproduce the Bug or Issue
- Go to https://stackblitz.com/edit/github-t8vtvecd?file=src%2Froutes%2Fabout.tsx,package.json
- Ctrl + c in terminal
tsr generate-> all good- update version to 1.166.31
- npm install
tsr generatefails withexpected route id to be a string literal or plain template literalasAboutpage has dynamic part.
Expected behavior
I would expect it to continute working. One of the best Tanstack Router features for our platform as we need to support deep variations for different markets.
Screenshots or Videos
No response
Platform
@tanstack/router-cli@1.166.30
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the linked StackBlitz example by running tsr generate on router-cli@1.166.30 and again on 1.166.31. Start by tracing route generation and reviewing PR 7167; done means the example and equivalent plain template literals generate successfully on the newer version without weakening the stated route-id validation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100