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

clearOnDefault doesn't work with createSerializer #641

Closed
hugotiger opened this issue Sep 18, 2024 · 3 comments · Fixed by #642
Closed

clearOnDefault doesn't work with createSerializer #641

hugotiger opened this issue Sep 18, 2024 · 3 comments · Fixed by #642
Labels
bug Something isn't working released

Comments

@hugotiger
Copy link
Contributor

hugotiger commented Sep 18, 2024

Context

What's your version of nuqs?

"nuqs": "1.19.1"

Next.js information (obtained by running next info):

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:59 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6030
  Available memory (MB): 36864
  Available CPU cores: 11
Binaries:
  Node: 20.11.1
  npm: 10.2.4
  Yarn: 1.18.0
  pnpm: N/A
Relevant Packages:
  next: 14.2.11 // There is a newer version (14.2.12) available, upgrade recommended! 
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.5.4
Next.js Config:
  output: N/A
 ⚠ There is a newer version (14.2.12) available, upgrade recommended! 
   Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
   Read more - https://nextjs.org/docs/messages/opening-an-issue

Are you using:

  • ✅ The app router
  • ❌ The pages router
  • ❌ The basePath option in your Next.js config
  • ❌ The experimental windowHistorySupport flag in your Next.js config

Description

The clearOnDefault option does not seem to work when using createSerializer. Seeing as TS was happy I expected it to work. I love this feature from the hooks so would be amazing getting it to work!

Let me know if I should attempt adding/fixing this and I'll take a stab at it :)

Reproduction

I skipped creating a CodeSandbox playground since it's very easy to explain. Let me know if I still should create one 😄

const serialize = createSerializer({
    int: parseAsInteger.withOptions({ clearOnDefault: true }).withDefault(0)
})
const result = serialize({ int: 0 })
//    ^ Result is `?int=0`
@hugotiger hugotiger added the bug Something isn't working label Sep 18, 2024
@franky47
Copy link
Member

Ah yes, that would make sense for the serializer to follow this setting. If you want to open a PR, that'd be great, thanks!

@hugotiger
Copy link
Contributor Author

hugotiger commented Sep 19, 2024

Ah yes, that would make sense for the serializer to follow this setting. If you want to open a PR, that'd be great, thanks!

Awesome! I've opened #642 where I seem to have fixed it, but haven't figured out how to type it properly yet so it has some @ts-expect-error directives. Can continue looking into it when I have some more time!

Copy link

🎉 This issue has been resolved in version 1.19.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants