zod
zod copied to clipboard
Having `undefined` as a function that can be imported is a package design issue
Hi everyone,
First of all, we like zod
a lot, it is an excellent tool for its job. However I feel that having an undefined
function that can be imported separately (see example below) is a metaphorical rake lying in the grass that I am stepping on way too frequently. After a while my subjective opinion is that there should be no separately importable undefined
variables in zod
, because it just creates much confusion.
// This just happens and then 💥
import { undefined } from 'zod';
Any postfix/prefix could fix it, in my opinion.
If it's only me who is stepping on this rake, then just close this.
Perhaps this will help: https://github.com/colinhacks/zod?tab=readme-ov-file#basic-usage
import { z } from "zod";
Perhaps this will help: https://github.com/colinhacks/zod?tab=readme-ov-file#basic-usage
import { z } from "zod";
I am well aware of this usage, however the way too friendly IDEs wish to import this function and more often than not we end up importing undefined
.
What would you like to have happen with this issue?
- Leave open as an enhancement request
- Move to discussions where we could look into workarounds for your specific use case
It's pretty rakey, but I've personally never seen Zod's undefined
beat out the built-in in autocomplete. If this is happening for a non-trivial fraction of users, it's something that should be addressed. We'll leave it open to see if reactions start coming in.
This issue happens semi-frequently for me. My IDE will auto-import undefined
. I use IntelliJ if that matters.
This just happened to me using PyCharm where undefined
was auto-imported from zod when typing out a if (isBoolean === undefined)
condition.
Issue comes up all the time for me in intellij as well :).
It's an IntelliJ ecosystem problem it seems. Probably they will point out that they don't want custom logic written for 1 library and you will probably point out that this only affects IntelliJ ecosystem users.