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

Unknown type after 0.8.2 update #67

Closed
spacepolice10 opened this issue Jan 29, 2024 · 4 comments
Closed

Unknown type after 0.8.2 update #67

spacepolice10 opened this issue Jan 29, 2024 · 4 comments

Comments

@spacepolice10
Copy link

Hi there, thank you for the great job done over this library

I found out that after updating to any versions newer than 0.8.1, VSCode and build tools (webpack, turbopack) say that type of atomWithQuery is unknown. Typescript doesn't help to provide correct typings related to Tanstack Query Core for some reason and Jotai itself can't handle such atoms using get & set. I tried it on Next.js 14.1.0 with jotai-tanstack-query 0.8.3. Same thing happens on any atomWithQuery no matter what settings are passed to inner objects. Anything I can do about that. For now I just switched back to 0.8.1. and it runs fine. Thank you for any info in advance

@EloToJaa
Copy link

EloToJaa commented Jan 30, 2024

Hi, I have a similar problem as @spacepolice10
Repo

For example in file ./src/atoms/quiz.ts

export const quizNameAtom = atom<string>(
  get => get(quizAtom).data?.data.name ?? "Go Back"
);

export const quizLengthAtom = atom<number>(
  get => get(quizAtom).data?.data.questions.length ?? 0
);

export const quizAtom = atomWithQuery(get => ({
  queryKey: ["quiz", get(userNameAtom), get(quizSlugAtom)],
  queryFn: () =>
    api.get<QuizResponse>(
      `/api/v1/Quiz/${get(userNameAtom)}/${get(quizSlugAtom)}`
    ),
}));

I get this errors

src/atoms/quiz.ts:21:10 - error TS2571: Object is of type 'unknown'.

21   get => get(quizAtom).data?.data.name ?? "Go Back"
            ~~~~~~~~~~~~~

src/atoms/quiz.ts:25:10 - error TS2571: Object is of type 'unknown'.

25   get => get(quizAtom).data?.data.questions.length ?? 0
            ~~~~~~~~~~~~~

package.json

@mfisher87
Copy link

Thank you so much for opening this issue, it saved me tons of time debugging ❤️ ❤️ ❤️

@kalijonn
Copy link
Collaborator

#68 should fix this. There's still some inconsistency around types but this should bring it back to 0.8.1.

Let me know if its still broken.

@EloToJaa
Copy link

It works now. Thanks.

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

No branches or pull requests

4 participants