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

Routes with required parameters has no intellisense on parameters #803

Open
rrmesquita opened this issue Jan 9, 2025 · 6 comments
Open
Assignees

Comments

@rrmesquita
Copy link

rrmesquita commented Jan 9, 2025

Ziggy version

2.4.2

Laravel version

none

Description

As the title says, when a route contains required parameters, intellisense is lost.

This is easily reproduceable within tests/js/route.test-d.ts, so there is no relevant information to put in the other fields of this issue.

Steps to reproduce

  1. Open tests/js/route.test-d.ts

  2. On line 25, remove the comment parameter and hit Ctrl/Cmd + Space to view suggested intellisense and assert it shows generic stuff instead of actual parameters.

Screenshot 2025-01-09 at 13 24 55
  1. On the posts.comments.show route declaration (line 11), make the post parameter optional by changing required to false .

  2. Again on line 25, hit Ctrl/Cmd + Space again and assert it suggests the "correct" information about the route parameters.

Screenshot 2025-01-09 at 13 26 57
@bakerkretzmar
Copy link
Collaborator

What editor/IDE is that?

@bakerkretzmar bakerkretzmar self-assigned this Jan 9, 2025
@rrmesquita
Copy link
Author

rrmesquita commented Jan 9, 2025

I used VS Code for that demonstration

edit: I attempted to use github.dev but I didn't know how to install dependencies, so I switched to VS Code

@stefanocurnis
Copy link

I does not work in PHPStorm too

@bakerkretzmar
Copy link
Collaborator

Weird. It seems like it's only the first required param, if I add another route with several required params as soon as I enter one of them the others are suggested. No clue what's going on here. This might be over my head in terms of the level of TypeScript going on but I'll keep thinking about it.

@rrmesquita
Copy link
Author

@bakerkretzmar do you mind providing that example? I couldn't reproduce it.

@bakerkretzmar
Copy link
Collaborator

bakerkretzmar commented Jan 31, 2025

Sorry I didn't explain it very well and I wasn't exactly right. This only happens when there are missing required parameters—as soon as all the required parameters are entered, the other (optional) ones are suggested correctly.

With the existing posts.comments.show route in the test file, if you enter route('posts.comments.show', { post: 1 }) and then go to add another parameter and press ctrl+space, it suggests comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants