8000 fix(nuxt): add overloads for `asyncData` generic + default by 94726 Β· Pull Request #22258 Β· nuxt/nuxt Β· GitHub
[go: up one dir, main page]

Skip to content

fix(nuxt): add overloads for asyncData generic + default #22258

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

Merged
merged 3 commits into from
Jul 23, 2023

Conversation

94726
Copy link
Contributor
@94726 94726 commented Jul 20, 2023

πŸ”— Linked issue

resolves #22164

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Adds overloads to useFetch and useAsyncData (+Lazy variants) for handling the correct type of the default function while also changing the type of data from DataT | null to DataT when providing a default.

I tried implementing it without adding even more overloads, but I just couldn't figure it out :/

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@danielroe
Copy link
Member

Thank you! Would you mind adding some tests to test/fixtures/basic-types/types.ts to cover these changes?

Copy link
Member
@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you ❀️

@danielroe danielroe changed the title fix(nuxt): adds overloads for asyncData defaults fix(nuxt): add overloads for asyncData generic + default Jul 23, 2023
@danielroe danielroe merged commit 7046930 into nuxt:main Jul 23, 2023
@github-actions github-actions bot mentioned this pull request Jul 23, 2023
@qoo1476
Copy link
qoo1476 commented Jul 24, 2023

resolves #21277 too, thanks

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

Successfully merging this pull request may close these issues.

TypeScript type error in useFetch default option with ResT generic and transform returning unknown when making external server requests
3 participants
0