-
Notifications
You must be signed in to change notification settings - Fork 251
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
feat: generate types that match generated js #692
base: 2.x
Are you sure you want to change the base?
Conversation
Very interested in making this work but need to think it through some more. We can't always count on being able to import from |
Thinking out loud—could this be an option for the |
If the I see two types of people that would want these type definitions:
How problematic it would be to just require the user to install the npm package – which is super lightweight – at least as a dev dependency? If you think about, it makes sense, it fixes the issue, and it saves us from having to implement a not so elegant solution. Let me know your thought and if there's another use-case I'm missing. |
Definitely not going to require installing the npm package, the goal is for almost everyone to never need it. |
Hi! From what I can figure out, the TS user of this package is required to set up their 'ziggy-js' dependency in some way anyway (either via tsconfig, or by having a NPM module). This is written in the TS section of the docs. So, I'm not sure what is the problem of importing from 'ziggy-js' in the TS context — it should be available in one way or the other. Besides, the current generated d.ts gives glaring TS error anyway. I have tested the code suggested here, and it works fine. How about we proceed with this fix? I should point out that the import in the suggested code should probably be changed to this one:
Related: #702 |
Right now, the README already asks the user to add a piece of typing in a
.d.ts
file in order to make the IDE aware of the globalroute
function. Since this function is global and always available, I don't see a reason to leave that step to the user.Another problem that this PR solves, is the error message shown when you want to import the Ziggy config from the generated JS file into a TS file.
I'll keep this as a draft for now, as this change would also require changes to tests and the README. Let me know your thoughts, and thanks for creating this awesome lib that helps me a lot!