typescript

package
v1.33.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package typescript implements the TypeScript protobuf compiler.

Index

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 New

func New(log *logger.Logger, opts *Options) *Compiler

New creates a new TypeScript compiler

func (*Compiler) Compile

Compile compiles the given proto files to TypeScript

func (*Compiler) GenerateIndexFile added in v1.22.1

func (c *Compiler) GenerateIndexFile(outputDir string, generatedFiles []string) error

GenerateIndexFile creates a single index.ts barrel after all TS files are generated.

func (*Compiler) GetOutputPath

func (c *Compiler) GetOutputPath(file compiler.ProtoFile, opts compiler.CompileOptions) string

GetOutputPath returns the output path for a proto file

func (*Compiler) Name

func (c *Compiler) Name() string

Name returns the compiler name

func (*Compiler) RequiredTools

func (c *Compiler) RequiredTools() []string

RequiredTools returns the list of required external tools

func (*Compiler) Validate

func (c *Compiler) Validate() error

Validate checks if the compiler is properly configured

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL