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

[solid-query] queryOptions() erases error type #8460

Closed
grobitto opened this issue Dec 20, 2024 · 1 comment · Fixed by #8472
Closed

[solid-query] queryOptions() erases error type #8460

grobitto opened this issue Dec 20, 2024 · 1 comment · Fixed by #8472

Comments

@grobitto
Copy link

grobitto commented Dec 20, 2024

Describe the bug

When I am using queryOptions helper type of error erased and becomes unknown

Your minimal, reproducible example

https://stackblitz.com/edit/tanstack-query-shfzdsbz?file=src%2Findex.tsx

Steps to reproduce

see example above

Expected behavior

query.error type does not get erased

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

all

Tanstack Query adapter

solid-query

TanStack Query version

5.62.8

TypeScript version

Version 5.6.3

Additional context

Looks like an easy fix: just change TError=unknown to TError = DefaultError in /solid-query/src/queryOptions.ts, but I am no TS expert and maybe the problem is deeper

@Nick-Lucas
Copy link
Contributor

This will be because the default type of TError in queryOptions is unknown and what you've passed in doesn't override this

There might be a good case to change TError = unknown to TError = DefaultError on queryOptions()

Otherwise you can define this yourself with queryOptions<Data, Error, ...etc> or by datatagging your query key ['key'] as DataTag<string[], Data, Error>

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

Successfully merging a pull request may close this issue.

2 participants