Git Product home page Git Product logo

protoc-gen-ts's Introduction

Protoc Gen Typescript

conformance test npm npm npm

Compile .proto files to plain TypeScript. Supports gRPC Node and gRPC Web.

Note

As of 2024, this project has adopted Rust as its primary programming language, replacing JavaScript. See the issue for the details.

Contributing

I have limited availability to consistently maintain this project, as my time is primarily allocated to cutting new releases and implementing fixes on an ad hoc basis.

See issues that needs help

See issues for newcomers

Become a maintainer? Send an email

Features

  • Passes all required conformance tests
  • Supports well-known types
  • Supports gRPC (@grpc/grpc-js)
  • Supports gRPC Web (grpc-web)
  • Supports json encoding (toJson, fromJson)
  • Supports binary encoding (toBinary, fromBinary)
  • Optimized for [de]serialization speed.

Usage

npm install -g protoc-gen-ts

Protoc

protoc -I=sourcedir --ts_out=dist myproto.proto

Buf

version: v1
plugins:
  - name: ts
    path: ./node_modules/.bin/protoc-gen-ts
    out: ./dist

Example

syntax = "proto3";

enum Role {
    ADMIN = 0;
    MOD = 1;
}

message Author {
    Role role = 2;
    oneof id_or_name {
        string id = 4;
        string name = 5;
    }
}
const author = Author.fromJson({
    role: Kind.ADMIN,
    name: "mary poppins",
});

// Serialize to binary
const bytes: Uint8Array = author.toBinary();

// Deserialize from binary
const received: Change = Change.fromBinary(bytes);

console.log(received.toJson())

Development

./infra/test.sh

Contributors

GitHub Contributors Image

Support

We need your constant support to keep protoc-gen-ts well maintained and add new features.

If your corporate has a OSS funding scheme, please consider supporting us monthly through open collective.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.