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

getCachedData makes useAsyncData resolve to type any #26761

Closed
warflash opened this issue Apr 12, 2024 · 3 comments
Closed

getCachedData makes useAsyncData resolve to type any #26761

warflash opened this issue Apr 12, 2024 · 3 comments

Comments

@warflash
Copy link
Member

Environment


  • Operating System: Windows_NT
  • Node Version: v18.18.2
  • Nuxt Version: 3.11.2
  • CLI Version: 3.11.1
  • Nitro Version: 2.9.6
  • Package Manager: [email protected]
  • Builder: -
  • User Config: devtools
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/warflash/nuxt-cached-data-type
Tested for TypeScript 5.4.3 and 5.4.5 in vscode and vscode insiders.

Describe the bug

Not setting getCachedData:
image

With getCachedData:
image

Additional context

No response

Logs

No response

@OrlS15
Copy link
Contributor

OrlS15 commented Apr 17, 2024

Same as #25903.
Seems that #25946 didn't solve the issue.

`Nuxt 3.11.2`

// data is 'number' (it should be a... string?)
const { data } = useAsyncData(async () => "this is a string", {
  getCachedData: () => 2,
});

// data2 is 'any' (it should be a string, right?)
const { data: data2 } = useAsyncData(async () => "this is a string", {
  getCachedData: (key) => useNuxtApp().payload.data[key],
});

IMHO the handler should choose the types and not getCachedData

@94726
Copy link
Contributor

94726 commented May 2, 2024

#25946 is not included in the latest version just yet and is scheduled for release in #26703

You can already try it using the nightly channel by updating your package.json

"nuxt": "npm:nuxt-nightly@latest"

@manniL
Copy link
Member

manniL commented May 2, 2024

Closing here as #25946 resolved it 👍🏻

@manniL manniL closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants