Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: Missing parameter for route when using glob pattern #6319

Closed
1 task
richcatt opened this issue Aug 27, 2022 · 5 comments · Fixed by #6364
Closed
1 task

[Bug?]: Missing parameter for route when using glob pattern #6319

richcatt opened this issue Aug 27, 2022 · 5 comments · Fixed by #6364
Assignees
Labels
bug/confirmed We have confirmed this is a bug topic/typescript

Comments

@richcatt
Copy link

What's not working?

I'm trying to change a couple of routes to use the glob param pattern, in order to work with nested items, e.g.:

<Route path='/category/{categoryIds...}/edit' page={CategoryEditCategoryPage} name='editCategory' />

This working fine when I manually enter the URL, but I get an error when creating navigate links, e.g.:

<Link to={routes.editCategory({ 'categoryIds...': category.id })}>Edit</Link>

image

How do we reproduce the bug?

https://gitpod.io#snapshot/f051b363-f867-42e0-8153-8c300d52439e

Navigate to categories list - https://8910-redwoodjs-gitpodstarter-im8r4cjqmdr.ws-eu63.gitpod.io/categories

What's your environment? (If it applies)

System:
    OS: Linux 5.15 Ubuntu 20.04.4 LTS (Focal Fossa)
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.13.2 - /tmp/xfs-12e552be/node
    Yarn: 3.2.0 - /tmp/xfs-12e552be/yarn
  Databases:
    SQLite: 3.31.1 - /usr/bin/sqlite3
  npmPackages:
    @redwoodjs/core: 2.2.3 => 2.2.3

Are you interested in working on this?

  • I'm interested in working on this
@richcatt richcatt added the bug/needs-info More information is needed for reproduction label Aug 27, 2022
@redwoodjs-bot redwoodjs-bot bot moved this to Triage in Main Aug 27, 2022
@redwoodjs-bot redwoodjs-bot bot added this to Main Aug 27, 2022
@richcatt
Copy link
Author

I'm assuming the syntax for the navigate link is as above, although if I remove the ... the app loads and functions correctly, e.g.:

<Link to={routes.editCategory({ 'categoryIds': category.id })}>Edit</Link>

However, I then get a TS error:

TS2345: Argument of type ‘{ categoryIds: any; }’ is not assignable to parameter of type ‘{ “categoryIds…”: string; } & QueryParams’. Property ‘“categoryIds…”’ is missing in type ‘{ categoryIds: any; }’ but required in type ‘{ “categoryIds…”: string; }’.

@jtoar
Copy link
Contributor

jtoar commented Sep 4, 2022

Hey @cattre thanks for the Gitpod snapshot! 🚀 As you mentioned in your second comment it looks like the types Redwood generates wrong. Let me step through babel-plugin-redwood-routes-auto-loader to see exactly what's going on there.

@jtoar jtoar assigned jtoar and unassigned simoncrypta Sep 4, 2022
@jtoar jtoar added bug/confirmed We have confirmed this is a bug topic/typescript topic/cli and removed bug/needs-info More information is needed for reproduction labels Sep 4, 2022
@jtoar
Copy link
Contributor

jtoar commented Sep 4, 2022

The generator also need updating so that the page it generates doesn't throw; it needs a parameter.

@jtoar jtoar moved this from Triage to Backlog in Main Sep 4, 2022
@jtoar
Copy link
Contributor

jtoar commented Sep 4, 2022

So turns out the utility type here doesn't handle glob routes, so this now very much a TS problem

@nbushe
Copy link

nbushe commented May 21, 2024

I had this problem because of a link without a parameter in the layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/confirmed We have confirmed this is a bug topic/typescript
Projects
None yet
4 participants