Skip to content
forked from Means88/tsbuf

Generate TypeScript enum and interface with proto buffer.

Notifications You must be signed in to change notification settings

PhilipMantrov/tsbuf

 
 

Repository files navigation

tsbuf npm@version Build Status Coverage Status

Generate TypeScript enum and interface with proto buffer.

Usage

npm install -g tsbuf
tsbuf example/proto -o example/typescript/global
# or
tsbuf example/proto -o example/typescript/module -m module
 

See example/

$ tsbuf -h
Usage: tsbuf [options] <inputPath> 

protobuf-parser
Generate TypeScript interface with Protobuf.

Options:
  -V, --version          output the version number
  -o, --output <output>  output path (default: ".")
  -m, --mode <mode>      "global": Global Definition, "module": Module Definition (default: "global")
  -h, --help             output usage information

Example

syntax = "proto3";

enum Fruit {
  Apple = 0;
  Banana = 1;
}

message Package {
  string id = 1;
  float price = 2;
}

Will be transformed to

declare enum Fruit {
  Apple = 0,
  Banana = 1,
}

interface Package {
  id: string;
  price: number;
}

Or TypeScript module

export enum Fruit {
  Apple = 0,
  Banana = 1,
}

export interface Package {
  id: string;
  price: number;
}

Roadmap

  • Basic Support
  • ExtendedType Field
  • Cli
  • Oneof Field
  • Map Field
  • Nested Type
  • Generate Global Declaration
  • Import (Generate Module)
  • Other Options

License

MIT

About

Generate TypeScript enum and interface with proto buffer.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 93.2%
  • JavaScript 6.8%