Find Related products on Amazon

Shop on Amazon

Show HN: Zero-codegen, no-compile TypeScript type inference from Protobufs

Published on: 2025-04-30 01:41:03

Zero-codegen, no-compile TypeScript type inference from protobuf message s. protobuf-ts-types lets you define language-agnostic message types in proto format, then infers TypeScript types from them with no additional codegen. Try on github.dev | View on CodeSandbox Warning Proof of concept, not production ready. See Limitations below for more details. How it Works In short, aggressive use of TypeScript's template literal types. Annotated example from the source: // Pass the proto string you want to infer `message` names from as a generic parameter type MessageNames < Proto extends string > = // Infer `message` parts using template literal type WrapWithNewlines < Proto > extends `${ string } ${ Whitespace } message${ Whitespace } ${infer MessageName } ${ OptionalWhitespace } {${ string } }${infer Rest } ` ? // Recursively infer remaining message names [ MessageName , ... MessageNames < Rest > ] : [ ] ; See more in src/proto.ts . Usage First, install the package. npm install ht ... Read full article.