tsgen

package
v0.84.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Comment

func Comment(s string) string

func GenerateTSContent

func GenerateTSContent(opts Opts) (string, error)

func GenerateTSToFile

func GenerateTSToFile(opts Opts) error

GenerateTSToFile generates a TypeScript file from the provided Opts.

func StringUnion

func StringUnion(strs []string) string

func TypeUnion

func TypeUnion(typeVars []string) string

Types

type AdHocType

type AdHocType = tsgencore.AdHocType

type ArbitraryProperty

type ArbitraryProperty struct {
	Name  string
	Value any
}

Anything you'd like to add to a TypeScript type object, other than the phantom types. Value must be JSON-serializable.

type CollectionItem

type CollectionItem struct {
	ArbitraryProperties map[string]any
	PhantomTypes        map[string]AdHocType
}

CollectionItem represents a TypeScript object type with arbitrary properties and phantom types. It will be added to a constant array in the generated TypeScript file with the name assigned to CollectionVarName in Opts.

type Opts

type Opts struct {
	// Path, including filename, where the resulting TypeScript file will be written
	OutPath string

	AdHocTypes []*AdHocType

	ExtraTSCode string

	Collection            []CollectionItem
	CollectionVarName     string // Defaults to "tsgenCollection"
	ExportCollectionArray bool
}

type Statements

type Statements [][2]string

func (*Statements) BuildString

func (m *Statements) BuildString() string

func (*Statements) Enum

func (m *Statements) Enum(constName, typeName string, enumStruct any) *Statements

func (*Statements) Raw

func (m *Statements) Raw(prefix string, value string) *Statements

func (*Statements) Serialize

func (m *Statements) Serialize(prefix string, value any) *Statements

type TSTyperRaw

type TSTyperRaw interface {
	TSTypeRaw() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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