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

feat: improve isNuxtError() type inference #28814

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

gianlucadifrancesco
Copy link
Contributor

🔗 Linked issue

resolves #28813

📚 Description

This PR will improve the type inference of isNuxtError(), without changing its implementation at all.

The change is a one-liner, very simple, but it offers several advantages:

  • Wider param type: the runtime code is already resilient to all parameter types, so its type is set to unknown to improve DX and avoid casting.
  • Always infer type: in this way, the type inference (error is NuxtError<DataT>) will always be applied after being asserted.
  • Mandatory param: I thought it was good to avoid using isNuxtError() without a param, as it's not particularly meaningful on its own.

Copy link

stackblitz bot commented Sep 3, 2024

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

@gianlucadifrancesco gianlucadifrancesco changed the title feat: improve isNuxtError type inference feat: improve isNuxtError() type inference Sep 3, 2024
@danielroe danielroe merged commit 0c9aa08 into nuxt:main Sep 3, 2024
40 checks passed
@danielroe
Copy link
Member

Thank you!

@github-actions github-actions bot mentioned this pull request Sep 3, 2024
@gianlucadifrancesco gianlucadifrancesco deleted the fix/isnuxterror-type branch September 3, 2024 21:51
@github-actions github-actions bot mentioned this pull request Sep 4, 2024
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.

Improve isNuxtError() type inference
2 participants