Skip to content

fullstorydev/protoc-gen-typescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

protoc-gen-typescript

A protoc plugin that generates typescript messages and service defitions. Notably: the generated messages can use native JSON serialization on a browser and do not require any generated marshalling code. The marshalling format is standard JSON Mapping.

Running

  • Install protoc
  • go install github.com/fullstorydev/protoc-gen-typescript/...@latest
  • protoc --typescript_out=<output dir> ...

enum

Enums are represented by integers, not strings, for both efficiency and version compatibility.

oneof

TODO: notes about oneof.

How types map between proto and typescript

See for more info: JSON Mapping.

Proto type Typescript Type Wire format
int64 protobuf.int64 string*
int32 number number
uint32 number number
sint32 number number
fixed32 number number
sfixed32 number number
sint64 protobuf.int64 string*
uint64 protobuf.uint64 string*
fixed64 protobuf.uint64 string*
sfixed64 protobuf.int64 string*
float number number
double number number
bool boolean boolean
string string string
Empty {} `{}
Timestamp protobuf.timestamp string*
Duration protobuf.duration string*
Any object json
Struct object json
Value unknown json
ListValue unknown[] json
  • Note: string wire format requires converstion to useful types, see below

google.protofbuf package

You will need typescript definitions for:

  • protobuf.timestamp
  • protobuf.duration
  • protobuf.int64
  • protobuf.uint64

There are helper methods to correctly convert between these wire format types and more useful Typescript representations.

Proto service definitions

TODO: notes about proto service definitions.

Go service integration and GRPC

TODO: notes about Go service integration and GRPC.

About

Protocol buffer to typescript for browser-based gRPC-over-HTTP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published