Skip to content

[query-client] Omit params property when there are no params #303

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

Closed
danielpza opened this issue Jul 15, 2023 · 7 comments
Closed

[query-client] Omit params property when there are no params #303

danielpza opened this issue Jul 15, 2023 · 7 comments

Comments

@danielpza
Copy link

danielpza commented Jul 15, 2023

Currently we need to pass an empty object as params even if no param is needed:

  client.test.useQuery(["something"], {
    query: { someQuery },
    params: {}, // cannot omit param object or ts complains
  });

The param property should be (imo) optional when it's not needed

@oliverbutler
Copy link
Collaborator

Hey this should be functioning already so I'm going to make as a bug and try write a failing test for this.

Thanks!

@oliverbutler oliverbutler added the bug Something isn't working label Jul 20, 2023
@oliverbutler oliverbutler added this to V3 Jul 20, 2023
@oliverbutler oliverbutler moved this to Todo in V3 Jul 21, 2023
@oliverbutler
Copy link
Collaborator

Hey @danielpza I can't create a minimal reproduction of this my side

Can you check that you're using strict mode in TS in this app?

Also can you send the contract you used for this EP please

@oliverbutler
Copy link
Collaborator

Image

Image

@oliverbutler oliverbutler moved this from Todo to In Progress in V3 Jul 26, 2023
danielpza added a commit to danielpza/ts-rest-issue-303 that referenced this issue Jul 26, 2023
@danielpza
Copy link
Author

Hey @oliverbutler, I was able to reproduce it here https://github.com/danielpza/ts-rest-issue-303

Can you check that you're using strict mode in TS in this app?

Yes I'm using strict mode

@oliverbutler
Copy link
Collaborator

Thank you! I'll take a look :)

@oliverbutler
Copy link
Collaborator

@danielpza I've found the reason your example doesn't work and I'm not seeing the issue my side, Zod.

Right now we rely on Zod for some underlying generics in @ts-rest/core

Installing Zod, even just effectively as a dev dependency should make this work for you.

We had an issue #44 but as of right now this isn't something we're working on removing, although not relying on Zod is definitely a goal of mine for ts-rest.

@oliverbutler oliverbutler removed the bug Something isn't working label Jul 27, 2023
@oliverbutler
Copy link
Collaborator

Closing for right now, but I'll see if we've adequately documented this limitation (I'm doubtful we did!)

@oliverbutler oliverbutler closed this as not planned Won't fix, can't repro, duplicate, stale Jul 27, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in V3 Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

No branches or pull requests

2 participants