Documentation
¶
Overview ¶
Package typescript implements the TypeScript protobuf compiler.
Index ¶
- type Compiler
- func (c *Compiler) Compile(ctx context.Context, files []compiler.ProtoFile, opts compiler.CompileOptions) (*compiler.CompileResult, error)
- func (c *Compiler) GenerateIndexFile(outputDir string, generatedFiles []string) error
- func (c *Compiler) GetOutputPath(file compiler.ProtoFile, opts compiler.CompileOptions) string
- func (c *Compiler) Name() string
- func (c *Compiler) RequiredTools() []string
- func (c *Compiler) Validate() error
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler implements the compiler.Compiler interface for TypeScript
func (*Compiler) Compile ¶
func (c *Compiler) Compile(ctx context.Context, files []compiler.ProtoFile, opts compiler.CompileOptions) (*compiler.CompileResult, error)
Compile compiles the given proto files to TypeScript
func (*Compiler) GenerateIndexFile ¶ added in v1.22.1
GenerateIndexFile creates a single index.ts barrel after all TS files are generated.
func (*Compiler) GetOutputPath ¶
GetOutputPath returns the output path for a proto file
func (*Compiler) RequiredTools ¶
RequiredTools returns the list of required external tools
type Options ¶
type Options struct {
// ProtocPath is the path to the protoc binary
ProtocPath string
// Generator selects the TS protobuf generator: "protoc-gen-ts" or "ts-proto"
Generator string
// ProtocGenTsPath is the path to the protoc-gen-ts plugin
ProtocGenTsPath string
// TsProtoPath is the path to the protoc-gen-ts_proto plugin
TsProtoPath string
// GenerateGrpc enables gRPC-Web or gRPC code generation
GenerateGrpc bool
// GenerateGrpcWeb uses grpc-web for browser compatibility
GenerateGrpcWeb bool
// GenerateNiceGrpc uses nice-grpc for server/client generation (ts-proto)
GenerateNiceGrpc bool
// ESModules enables ES module output (import/export) instead of CommonJS
ESModules bool
// OutputIndex generates an index.ts barrel file
OutputIndex bool
// PackageName is an optional npm package name for generated code
PackageName string
}
Options contains TypeScript-specific compilation options
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions returns default options for TypeScript compiler
Click to show internal directories.
Click to hide internal directories.