UNPKG

@protobuf-ts/plugin

Version:

The protocol buffer compiler plugin "protobuf-ts" generates TypeScript, gRPC-web, Twirp, and more.

51 lines (50 loc) 1.35 kB
import * as ts from "typescript"; import { DescriptorRegistry, EnumDescriptorProto, SymbolTable, TypescriptFile, TypeScriptImports } from "@protobuf-ts/plugin-framework"; import { CommentGenerator } from "./comment-generator"; import { Interpreter } from "../interpreter"; import { GeneratorBase } from "./generator-base"; export declare class EnumGenerator extends GeneratorBase { private readonly options; constructor(symbols: SymbolTable, registry: DescriptorRegistry, imports: TypeScriptImports, comments: CommentGenerator, interpreter: Interpreter, options: {}); /** * For the following .proto: * * ```proto * enum MyEnum { * ANY = 0; * YES = 1; * NO = 2; * } * ``` * * We generate the following enum: * * ```typescript * enum MyEnum { * ANY = 0, * YES = 1, * NO = 2 * } * ``` * * We drop a shared prefix, for example: * * ```proto * enum MyEnum { * MY_ENUM_FOO = 0; * MY_ENUM_BAR = 1; * } * ``` * * Becomes: * * ```typescript * enum MyEnum { * FOO = 0, * BAR = 1, * } * ``` * */ generateEnum(source: TypescriptFile, descriptor: EnumDescriptorProto): ts.EnumDeclaration; }