Giter Site home page Giter Site logo

stringang / protoc-gen-tsd Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 643 KB

Protocol Buffers Compiler(protoc) plugin for TypeScript - Generate definition file(d.ts)

JavaScript 2.60% TypeScript 96.90% Batchfile 0.51%
protocol-buffers protoc protoc-plugin protobuf typescript protocol-compiler proto3 grpc-node grpc

protoc-gen-tsd's Introduction

protoc-gen-tsd

npm GitHub release (latest by date)

Protoc Plugin for generating TypeScript definition

The library exports the protoc-gen-tsd executable, which generates a TypeScript definition file(.d.ts file).

Quick Start

Installation

npm install protoc-gen-tsd

Usage

export PATH=./node_modules/.bin:$PATH
# single .proto file
protoc --tsd_out=./examples/protos ./examples/protos/echo.proto
# multiple .proto file
protoc --tsd_out=./examples/protos -I=./examples/protos ./examples/protos/*.proto

Packaging Comparison

Some time ago, gRPC released pure JavaScript implementation of client @grpc/grpc-js without a C++ addon.

The @grpc/grpc-js load package definition object(grpc.loadPackageDefinition) requires a @grpc/proto-loader to load the proto file.

@grpc/grpc-js serialization and deserialization protocol buffer messages depend on the @grpc/proto-loader output package definition object.

When we get the protocol buffer message, it has been deserialized and we can get the information directly from the property accessor.

So, to work with TypeScript you only need to declare the type protobuf message.

.d.ts file protoc-gen-tsd ts-protoc-gen
get/set field ✔️
google-protobuf dependency ✔️
grpc dependency ✔️
@grpc/grpc-js dependency ✔️

Examples

Debug

#!/usr/bin/env node --inspect-brk --require ts-node/register ./src/index.ts
export PATH=./bin:$PATH
protoc --tsd_out=. examples/protos/echo.proto

ejs

<% debugger; %>

protoc-gen-tsd's People

Contributors

stringang avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.