zezhipeng / protoc-gen-ts

A Typescript Protocol Buffer Implementation from the Future :sparkles:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

protoc-gen-ts

A Typescript Protocol Buffer Implementation from the Future ✨

Notable features / gotchas

  • The generator has no dependancy on node.js, and is implemented as a standalone binary (golang)
  • Only supports proto3
  • Each .proto file generates a TS file, which is intended to be used as an es6 module. Protobuf namespaces are ignored.
  • Currently uses long.js for 64 bit integer support.
  • Maps use es6.Map in order to preserve compile time and runtime key types. There is an exception of 64 integer key types, which are converted to strings so that equality comparison works correctly.
  • Uses Direct property access instead of getter / setter functions.
  • Oneofs are implemented as a Typescript 'union type'.
  • Generates service stubs that are transport agnostic.
  • It passes the conformance suite.

Example output

There are a couple example .proto files in the test directory, the corresponding output is in the test/gen-src directory.

TODOs

  • Proto3 JSON
  • Wellknown types
  • Benchmarking: Probably lots of optimizations to be had.
  • Internalize the long.js dependancy?
  • Embed Descriptors
  • Reflection
  • gRPC-Web?
  • Constructor arguments via a 'shape'

About

A Typescript Protocol Buffer Implementation from the Future :sparkles:

License:Other


Languages

Language:TypeScript 52.2%Language:Go 44.1%Language:Makefile 2.0%Language:Python 1.5%Language:Shell 0.2%