protobuf-ts-types

Languages and libraries

type system library

SHOW HN2025

protobuf-ts-types

Zero-codegen, no-compile TypeScript type inference from Protobufs

github.com

#typescript#protobuf#type inference#codegen

138points
73comments
#542of 3,837 in 2025
Top 15%of 2025 by points

How HN took it

DebatedReal support and real criticism

7 positive, 4 neutral or asking, 0 mixed, 6 critical, out of 17 comments about the project. Thread score +0.11.

Idea: 2 for, 2 againstPerformance: 0 for, 3 againstExecution: 2 for, 1 against

The thread, comment by comment

Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.

positive neutral or mixed critical about another commenter or something else the maker

What HN said

What people liked

  • Impressive use of TypeScript's type system; small, succinct source.

    From 3 comments
    • The fact that the source is so small is wild. I would have expected a huge convoluted parsing library implemented in types. On the other hand, the fact that this is even possible…
      mubou on HN
    • What's kind of amazing is that Typescript's matching of strings through the type system converges on a first-class PEG in a few places (see string.ts). The rest of the library is…
      pragma_x on HN
    • This is both hilarious and awesome. I think the Typescript devs are just showing off at this point. :D
      aappleby on HN
  • Cool zero-codegen approach that removes build steps.

    From 2 comments
    • This is super cool — love the zero-codegen approach. I’ve had to deal with codegen hell in monorepos where a tiny .proto change breaks half the pipeline. Curious how this handles…
      anjandutta on HN
    • I love this, and I bet the compile errors it produces on malformed protobuf are wild.
      throwanem on HN

Objections

  • Inline string only; the schema can't be read from .proto files due to TypeScript limits.

    From 3 comments
    • This requires the whole `.proto` declaration inline in source a string constant. I'm not holding my breath on "Import non-js content"[1] getting approved, so that means you still…
      recursive on HN
    • It's always impressive how far people can take TypeScript and even build parsers with it. But this is limited to inlined string literals and cannot read files (a TS limitation).…
      tim1994 on HN
    • Cool. Once the linked TS issue is resolved it will be able to resolve from files too which is great
      porridgeraisin on HN
  • Likely slow compile times and poor error messages from heavy type-level computation.

    From 3 comments
    • This is kinda why I hate advanced type systems, they slowly become their own language. "No compile/no codegen" sounds nice until you get slow compile times because a type system…
      mherkender on HN
    • It’s pretty rad how flexible template literal types are, but I can’t imagine wanting this kind of shenanigans hanging out in a production app slowing down compile times. I prefer…
      jitl on HN
    • Cool, but I assume not great for performance? Probably better to just stick with codegen
      jillyboel on HN

Requests

  • Support for nested messages and oneof fields.

    From 1 comment
    • This is super cool — love the zero-codegen approach. I’ve had to deal with codegen hell in monorepos where a tiny .proto change breaks half the pipeline. Curious how this handles…
      anjandutta on HN
  • Support for importing non-JS file content in TypeScript.

    From 1 comment
    • This requires the whole `.proto` declaration inline in source a string constant. I'm not holding my breath on "Import non-js content"[1] getting approved, so that means you still…
      recursive on HN

Questions

  • What is the use case, given protobuf is needed for non-TS interop?

    From 1 comment
    • It's always impressive how far people can take TypeScript and even build parsers with it. But this is limited to inlined string literals and cannot read files (a TS limitation).…
      tim1994 on HN
  • Is it fast enough for performance and IDE use?

    From 1 comment
    • Cool, but I assume not great for performance? Probably better to just stick with codegen
      jillyboel on HN

Alternatives named

  • Traditional protobuf codegen tools.

    From 2 comments
    • Cool, but I assume not great for performance? Probably better to just stick with codegen
      jillyboel on HN
    • This requires the whole `.proto` declaration inline in source a string constant. I'm not holding my breath on "Import non-js content"[1] getting approved, so that means you still…
      recursive on HN
  • Generating proto from TypeScript types or TypeSpec.

    From 2 comments
    • It’s pretty rad how flexible template literal types are, but I can’t imagine wanting this kind of shenanigans hanging out in a production app slowing down compile times. I prefer…
      jitl on HN
    • This makes me wonder if this the way to do schema generation in Typescript. I’m working on Typeconf, and we have a separate step for translating Typespec schema to Typescript,…
      mifydev on HN

Category, keywords, summaries and labels on this page were made by AI (Thread Reader v2) and not checked by hand. Each point links to the comments it came from.

Add a badge to your READMEShown on HackerShow
[![Shown on HackerShow](https://hackershow.org/badge.svg)](https://hackershow.org/show/43682547)