proto_ts_schema

raw JSON →
1.0.1 verified Fri May 01 auth: no javascript

A CLI tool and library to compile/transpile Protocol Buffer .proto files into TypeScript interfaces and schemas. Current stable version is 1.0.1. Provides a configurable build system with CLI via `p2ti`. Key differentiators include support for relative imports, config file (JS/TS), and a declarative approach. However, it is early-stage with known caveats like message ordering dependency. Not as mature as alternatives like protobuf-ts or ts-proto. Ships TypeScript definitions.

error Error: Proto doesn't have the message named
cause The .proto file references a message before it is defined (ordering issue).
fix
Reorder messages in the .proto file so that all referenced messages are defined before their first use.
gotcha Message ordering in .proto files matters: a message must be defined before it is used or it will cause an error.
fix Reorder proto definitions so that referenced messages appear earlier in the file.
gotcha The package expects a config file at CWD/p2t.js by default; if missing, it may silently use defaults or error.
fix Ensure a config file exists at the working directory or pass --config explicitly.
gotcha No programmatic API is documented; only CLI usage is supported.
fix Use the CLI via shell or child_process.exec to invoke transpilation.
npm install proto_ts_schema
yarn add proto_ts_schema
pnpm add proto_ts_schema

Installs the package globally, creates a minimal config file, and runs the CLI to transpile a proto file to TypeScript.

npm install -g proto_ts_schema
# Create a config file (p2t.js) in current directory
module.exports = {
  // optional config
};
# Run the CLI with default options
p2ti -p ./protos -o ./out -f message.proto