TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Zod v4 Beta

177 点作者 mycroft_4221大约 1 个月前

14 条评论

move-on-by大约 1 个月前
I only use Zod in a single library, so my experience with it is pretty minimal. One thing I have really enjoyed with it is the low maintenance.<p>So, when I saw this post and read the first few paragraphs, I was filled with dread for having to do yet another major dependency update. Reading of all the improvements- surly the ‘breaking changes’ list must be massive.<p>Having read the full article, it seems like the breaking changes have been kept within reason. One major improvement that stands out to me is the improved Recursive types support, but there is certainly any number of improvements for others to be excited about.<p>The thing I enjoyed most is that excitement of the Arthur really shines throughout the whole article. I’m so thankful this library exists and is being lovingly maintained by someone who is genuinely interested in it.
评论 #43708330 未加载
评论 #43672833 未加载
评论 #43670220 未加载
Rodeoclash大约 1 个月前
We stuck with Yup and ignored Joi, Zod and god knows what else has come down the pipeline since. Rather than wasting time upgrading, we&#x27;ve instead built useful features.<p>That said, we are slowly phasing out our React frontend for one of our apps page by page and replacing it with what we use over the rest of apps: Phoenix + Liveview. The changeset system for validations has proven itself time and time again to both be fast but also to handle many of the curly validation problems we might have. It also has barely changed since its release.<p>If you have a disciplined frontend team then you might be able to make it work. They have to be able to ignore the latest shiny thing that has come along, but if you don&#x27;t then you&#x27;ll have a team that is busy constantly upgrading to the latest shiny library rather than getting anything done.
评论 #43668752 未加载
评论 #43670124 未加载
评论 #43670083 未加载
评论 #43670933 未加载
adriancooney大约 1 个月前
Zod is installed in nearly every project I use. It’s an essential part of my toolkit. I adore this library. It near perfect as-is and these additions make it even better. Thanks for all the hard work.
评论 #43668826 未加载
_fat_santa大约 1 个月前
My team has been building a greenfield SaaS app for the past ~9 months and when we started, we went all in on Zod and so far the experience has been pretty fantastic. Zod is very intuitive to use and being able to generate typescript types off the schemas is very useful. Though with that said if you&#x27;re already using Yup or Joi I don&#x27;t recommend switching as there&#x27;s just not enough of a reason to switch over.
petesergeant大约 1 个月前
Feature list looks awesome, especially:<p>&gt; Zod 4 introduces first-party JSON Schema conversion via z.toJSONSchema().
gajus大约 1 个月前
Surprised not to see more people ask about performance profile of v4.<p>Zod is great in terms of API, but a no-go in terms of performance.<p>We ended up writing babel plugins (<a href="https:&#x2F;&#x2F;github.com&#x2F;gajus&#x2F;babel-plugin-zod&#x2F;">https:&#x2F;&#x2F;github.com&#x2F;gajus&#x2F;babel-plugin-zod&#x2F;</a>) and using it along with zod-accelerator, which improves performance, but breaks in various edge-cases.
评论 #43668980 未加载
cianuro_大约 1 个月前
I completely understand TypeScript, Zod not so much. The context here is performance.<p>My understanding is that Zod performs synchronous operations to validate the schemas. Something about &quot;using the tool correctly&quot; resonates here. Maybe don’t validate very large and nested schemas frequently and things like that.<p>But I can’t help but think it is adding another layer of potential footguns that you have to be mindful about. Maybe the benefits outshine the risks in disciplined teams that understand both the tool and the runtime. However I can’t help but think about the less disciplined teams abusing Zod and then wondering why things are slow.
评论 #43670282 未加载
评论 #43672042 未加载
_heimdall大约 1 个月前
I&#x27;ve created some crazy types with zod since v3 released, these look like really interesting changes for v4.<p>I&#x27;ve been bit by performance issues, and even a few issues where I just couldn&#x27;t infer types, with some of the more complex schemas I tried to define, especially with multiple .extend() and .omit() calls.<p>The zod-mini library looks particularly interesting. I don&#x27;t mind the more functional approach with nested functions rather than chaining. Reminds me of ramda, that library is pretty massive but still easy to tree shake since everything is functional.
mary-ext大约 1 个月前
This is awesome, bundle size has been my number one issue preventing me from trying out Zod as v3 shipped with validations that were unnecessary for frontend use but weren&#x27;t able to be treeshaken.
评论 #43668615 未加载
cjonas大约 1 个月前
I&#x27;ve really enjoyed typebox. Any reason to check out zod v4?
评论 #43669647 未加载
machiaweliczny大约 1 个月前
Were union types fixed? I remember that previously they didn’t work too well.
darepublic大约 1 个月前
Zod is useful but it&#x27;s something I use sparingly. Go too ham with it you end up with type errors that are paragraphs long.
评论 #43669159 未加载
aleksiy123大约 1 个月前
All I can say is looks really good.
jmull大约 1 个月前
&gt; Zod v3.0 was released in May 2021...<p>v3 didn&#x27;t last four years. Can we expect much different from v4?<p>If you&#x27;re migrating your zod 3 code, I&#x27;d migrate to something more stable and long-lived than v4 is likely to be -- unless you want to be going through it all again in a few years (and yet again a few years after that, etc).<p>I don&#x27;t blame the maintainers (I assume they don&#x27;t have a fat support and maintenance contract)<p>But developers need to go in with their eyes open when it comes to adopting these throw-away libraries and frameworks.
评论 #43668634 未加载
评论 #43668626 未加载
评论 #43668636 未加载
评论 #43668608 未加载
评论 #43668628 未加载
评论 #43668646 未加载