Skip to content

feat(types): type $fetch to match json serialization output#1002

Merged
pi0 merged 6 commits into
nitrojs:mainfrom
mahdiboomeri:feat/serialize-fetch
Feb 28, 2023
Merged

feat(types): type $fetch to match json serialization output#1002
pi0 merged 6 commits into
nitrojs:mainfrom
mahdiboomeri:feat/serialize-fetch

Conversation

@mahdiboomeri

@mahdiboomeri mahdiboomeri commented Feb 27, 2023

Copy link
Copy Markdown
Contributor

🔗 Linked issue

resolves #804, resolves #1000

❓ 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 PR transforms the output type of $Fetch to better match what JSON.stringify returns (using trpc and remix implementation).

This is potentially a breaking change.

📝 Checklist

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

@codecov

codecov Bot commented Feb 27, 2023

Copy link
Copy Markdown

Codecov Report

Merging #1002 (e405cbb) into main (d83f2b6) will decrease coverage by 0.13%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1002      +/-   ##
==========================================
- Coverage   67.79%   67.66%   -0.13%     
==========================================
  Files          60       60              
  Lines        6133     6161      +28     
  Branches      692      692              
==========================================
+ Hits         4158     4169      +11     
- Misses       1966     1982      +16     
- Partials        9       10       +1     
Impacted Files Coverage Δ
src/types/fetch.ts 100.00% <100.00%> (ø)
src/build.ts 44.62% <0.00%> (-1.45%) ⬇️
src/rollup/plugins/esbuild.ts 54.41% <0.00%> (+1.07%) ⬆️
src/presets/lagon.ts 35.71% <0.00%> (+4.76%) ⬆️

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

@pi0 pi0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

💯

@pi0 pi0 requested a review from danielroe February 28, 2023 10:14
Comment thread src/types/serialize.ts Outdated

@danielroe danielroe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is really great.

I only have one suggestion, so we can avoid the super-permissive object type. Otherwise 👌

Co-authored-by: Daniel Roe <daniel@roe.dev>
@mahdiboomeri

Copy link
Copy Markdown
Contributor Author

@danielroe Thanks 💚, I've also updated the tests. It should be ready to go.

@pi0 pi0 merged commit fe6e579 into nitrojs:main Feb 28, 2023
@mahdiboomeri mahdiboomeri deleted the feat/serialize-fetch branch February 28, 2023 11:42
@danielroe

Copy link
Copy Markdown
Member

@mahdiboomeri Just to let you know we had to revert part of this as a hotfix owing to increased type complexity: see #1050. If you have any ideas, a PR would be most welcome 🙏

@danielroe danielroe mentioned this pull request Mar 14, 2023
@mahdiboomeri

Copy link
Copy Markdown
Contributor Author

@danielroe I think moving Serialize (and Simplify) to nitro-routes.d.ts can help. I did a quick experiment and it seems like it improves type checking duration.

Before:
Screenshot 2023-03-15 at 20-00-53 trace json (1 MB) - Perfetto UI

After:
Screenshot 2023-03-15 at 20-00-33 trace json (1 MB) - Perfetto UI

Is there any reproduction on this?

@danielroe

Copy link
Copy Markdown
Member

Previously, it reproduced in the Nuxt test:types check.

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.

Auto infer types from .toJSON if property exisits Improve type-safety of $Fetch

4 participants