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

fix(types): Export Nullable type for correctly inferring return type of createSerializer() #801

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

MartinCura
Copy link
Contributor

@MartinCura MartinCura commented Dec 11, 2024

Bonsoir!* This PR fixes a type issue someone with my exact username 👀 introduced in #769, related to TypeScript.

It seems like TS has issues with inferring the type of the created serializer if it doesn't have access to the Nullable type, and I've been getting this very cryptic error:

The inferred type of 'serializeProductDetailParams' cannot be named without a reference to '@/node_modules/nuqs/dist/_tsup-dts-rollup'. This is likely not portable. A type annotation is necessary.

image

This PR solves this by simply exporting nuqs' Nullable type (for both client and server package entrypoints), if that's alright with you, and Nullable doesn't even have to be imported by app code to solve the TS issue.

I'm not sure why TS can't manage without this explicit export and from some issues i've skimmed it shouldn't be the correct behaviour maybe, but the solution presented here is quite simple.

*I came across your website and realized we're quite close right now, as i'm currently staying in Lyon. Small world! 🌍

For both client and server, solves TS issue
Copy link

vercel bot commented Dec 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nuqs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 11, 2024 1:17am

Copy link

vercel bot commented Dec 11, 2024

@MartinCura is attempting to deploy a commit to the 47ng Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Member

@franky47 franky47 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@franky47 franky47 changed the title fix(types): export Nullable type for correctly inferring return type of createSerializer() fix(types): Export Nullable type for correctly inferring return type of createSerializer() Dec 11, 2024
@franky47 franky47 merged commit ab99d7d into 47ng:next Dec 11, 2024
27 checks passed
@MartinCura MartinCura deleted the export_nullable_type branch December 11, 2024 14:11
Copy link

🎉 This PR is included in version 2.3.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

github-actions bot commented Jan 1, 2025

🎉 This PR is included in version 2.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@franky47 franky47 mentioned this pull request Jan 3, 2025
@franky47 franky47 removed this from the 🚀 Shipping next milestone Jan 3, 2025
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.

2 participants