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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Automatically generating types for Cloudflare Workers

57 点作者 tekkertje超过 3 年前

5 条评论

latchkey超过 3 年前
This recently bit me. No automated testing, so it broke production code.<p>You can brag about your automation, when it is well tested.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;cloudflare&#x2F;workers-types&#x2F;issues&#x2F;116" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cloudflare&#x2F;workers-types&#x2F;issues&#x2F;116</a>
brundolf超过 3 年前
Generated types are much better than manually-updated types when you&#x27;ve got a source of truth that lives in a different codebase, but I can&#x27;t help feel like we could do better. I wish there were a &quot;lingua franca&quot; for type declarations that could be understood directly by different languages. Not only would you avoid the mess that is generated source code, but it could be a n^2 -&gt; 2n situation, like LLVM and LSP, where you only have to translate to and from this common ground instead of to and from every combination of leaves.<p>Unfortunately it might be pretty challenging given how different type systems can be. But maybe if you started with a subset of popular languages that have similar-enough type concepts?
评论 #29254318 未加载
评论 #29247289 未加载
评论 #29248836 未加载
eminence32超过 3 年前
This is nice. I started to learn Cloudflare Workers a few months ago, and used TypeScript for my project. Since I was to this platform, I relied heavily on the TS types and tab completion in my IDE to explore the APIs and to make sure I was using them correctly. Unfortunately there were several gaps which lead to a less-than-ideal development experience and general confusion.
评论 #29246671 未加载
lukekim超过 3 年前
You can also do this manually with quicktype.io. We&#x27;ve found it useful from the number of languages it supports.
eyelidlessness超过 3 年前
Generated types are fine (if a bit cumbersome) when you trust input. When you don’t, “parse [don’t validate]” and produce static types at the place where input becomes a known quantity.