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

useAsyncData types are inferred from getCachedData and not from the handler #25903

Closed
OrlS15 opened this issue Feb 21, 2024 · 2 comments · Fixed by #25946
Closed

useAsyncData types are inferred from getCachedData and not from the handler #25903

OrlS15 opened this issue Feb 21, 2024 · 2 comments · Fixed by #25946

Comments

@OrlS15
Copy link
Contributor

OrlS15 commented Feb 21, 2024

Environment


  • Operating System: Windows_NT
  • Node Version: v21.5.0
  • Nuxt Version: 3.10.2
  • CLI Version: 3.10.1
  • Nitro Version: 2.8.1
  • Package Manager: pnpm@8.15.3
  • Builder: -
  • User Config: devtools
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-ptesuy?file=app.vue

Describe the bug

const { data: thisTypeIsCorrect } = await useAsyncData("test", async () => ({ hello: "world!" }));

const { data: thisTypeIsAny } = await useAsyncData("test2", async () => ({ hello: "world!" }), {
  getCachedData: (key) => useNuxtApp().payload.data[key],
});

useAsyncData types are inferred from getCachedData and not from the handler.
Is this the behavior it should have?

Additional context

No response

Logs

No response

Copy link

stackblitz bot commented Feb 21, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@edomod
Copy link

edomod commented Feb 22, 2024

I have the same problem

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

Successfully merging a pull request may close this issue.

3 participants