TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Automatically generating types for Cloudflare Workers

57 pointsby tekkertjeover 3 years ago

5 comments

latchkeyover 3 years ago
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>
brundolfover 3 years ago
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 未加载
eminence32over 3 years ago
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 未加载
lukekimover 3 years ago
You can also do this manually with quicktype.io. We&#x27;ve found it useful from the number of languages it supports.
eyelidlessnessover 3 years ago
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.