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

types: add generics to isError and update DataT default generic param #582

Merged
merged 2 commits into from
Nov 24, 2023

Conversation

DamianGlowala
Copy link
Contributor

πŸ”— Linked issue

❓ 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

Makes isError generic, hence removing the need to explictly annotate the return type of createError.

@pi0, shall we consider amending the default generic param for DataT from any to unknown, as per this discussion?

πŸ“ Checklist

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

Copy link

codecov bot commented Nov 22, 2023

Codecov Report

All modified and coverable lines are covered by tests βœ…

Comparison is base (0ff34bc) 84.43% compared to head (d5d921d) 84.43%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #582   +/-   ##
=======================================
  Coverage   84.43%   84.43%           
=======================================
  Files          32       32           
  Lines        3752     3752           
  Branches      556      559    +3     
=======================================
  Hits         3168     3168           
  Misses        584      584           

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

@pi0
Copy link
Member

pi0 commented Nov 22, 2023

@pi0, shall we consider amending the default generic param for DataT from any to unknown, as per nuxt/nuxt#24396 (comment)?

Would it be necessary for generic support? If yes, sure LGTM as breaking change surface for error data type seems low. (in general, i prefer any => unknown migrations in major versions but this seems small)

@pi0 pi0 requested a review from danielroe November 22, 2023 18:45
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.

This looks good to me. I'd recommend migrating to unknown here as @pi0 is happy to do it in a non major version. ❀️

src/error.ts Show resolved Hide resolved
@DamianGlowala DamianGlowala changed the title types: add generics to isError types: add generics to isError and update DataT default generic param Nov 22, 2023
@pi0 pi0 merged commit afc4183 into unjs:main Nov 24, 2023
6 checks passed
@pi0
Copy link
Member

pi0 commented Nov 24, 2023

Probably doing release by next week but you can try using nightly channels πŸ‘πŸΌ (And thanks!)

@DamianGlowala DamianGlowala deleted the types/generic-is-error branch November 24, 2023 14:08
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

Successfully merging this pull request may close these issues.

None yet

3 participants