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(types): correctly type $fetch based on the method #686

Merged
merged 11 commits into from
Dec 12, 2022
Merged

Conversation

dsluijk
Copy link
Contributor

@dsluijk dsluijk commented Nov 22, 2022

πŸ”— Linked issue

#685

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 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)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This feature fixed the types of the routes when used with $fetch, when there are multiple handlers with different methods for the same route. It detects the method given with the options, and returns the correct set of types for that call. This also works if you don't specify a method or if the handler does not specify a method.

This might be a breaking change, as it changes the format of InternalApi.

πŸ“ Checklist

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

I don't think a documentation update is needed here.

@dsluijk
Copy link
Contributor Author

dsluijk commented Nov 23, 2022

I've fixed the failing test and added a few new ones to assert the new types. The method option in a request is now also typed correctly with the methods available.

@codecov
Copy link

codecov bot commented Dec 8, 2022

Codecov Report

Merging #686 (3524149) into main (821b773) will decrease coverage by 4.94%.
The diff coverage is 82.97%.

❗ Current head 3524149 differs from pull request most recent head 9cff984. Consider uploading reports for the commit 9cff984 to get more accurate results

@@            Coverage Diff             @@
##             main     #686      +/-   ##
==========================================
- Coverage   72.01%   67.07%   -4.95%     
==========================================
  Files          57       57              
  Lines        5050     4267     -783     
  Branches      546      462      -84     
==========================================
- Hits         3637     2862     -775     
+ Misses       1403     1402       -1     
+ Partials       10        3       -7     
Impacted Files Coverage Ξ”
src/build.ts 40.20% <52.94%> (-9.51%) ⬇️
src/types/fetch.ts 100.00% <100.00%> (ΓΈ)
src/presets/firebase.ts 30.52% <0.00%> (-67.64%) ⬇️
src/dev/server.ts 21.15% <0.00%> (-50.34%) ⬇️
src/presets/azure-functions.ts 26.02% <0.00%> (-7.76%) ⬇️
src/presets/cloudflare.ts 47.72% <0.00%> (-7.63%) ⬇️
src/rollup/plugins/replace.ts 76.47% <0.00%> (-6.14%) ⬇️
src/scan.ts 59.30% <0.00%> (-6.05%) ⬇️
src/utils/index.ts 47.20% <0.00%> (-4.63%) ⬇️
... and 32 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

src/build.ts Outdated Show resolved Hide resolved
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 very nice - thanks! 😊

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