question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to tell zod to use nullish instead of nullable?

See original GitHub issue

I’m encountering many cases of:

Type 'number | null | undefined' is not assignable to type 'number | undefined'.

Using nullish instead for optional fields could solve this issue.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
CarterGrimmeisencommented, Jan 20, 2022

Published.

1reaction
CarterGrimmeisencommented, Jan 19, 2022

0.5.0 has been published with this change!

Read more comments on GitHub >

github_iconTop Results From Across the Web

nullable and .default · Issue #425 · colinhacks/zod - GitHub
In which case I request that a "default() for nulls" or "default() handles nulls" be added, since I cannot figure out a way...
Read more >
Why does Zod make all my schema fields optional?
I suggest to create a basic version and then extend it with 'passwordConfirmation' and relative refinement. Also is important ...
Read more >
TypeScript schema validation with Zod - Iskander Samatov
Schema validation will help you ensure that your data is valid during runtime and Zod is the one of the best TypeScript libraries...
Read more >
Nullish Coalescing: The ?? Operator in TypeScript
We can use this operator to provide a fallback value for a value that might be null or undefined . #Truthy and Falsy...
Read more >
JavaScript — Better way to check for Nullish values - Medium
We have seen the nullish coalescing operator is really useful when you only care about the null or undefined value for any variable....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found