tsgen

package
v0.0.87 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: BSD-3-Clause Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateTSContent added in v0.0.50

func GenerateTSContent(opts Opts) (string, error)

func GenerateTSToFile added in v0.0.50

func GenerateTSToFile(opts Opts) error

GenerateTSToFile generates a TypeScript file from the provided Opts.

Types

type AdHocType added in v0.0.50

type AdHocType = tsgencore.AdHocType

type ArbitraryProperty added in v0.0.50

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 added in v0.0.87

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 added in v0.0.65

type Statements [][2]string

func (*Statements) BuildString added in v0.0.77

func (m *Statements) BuildString() string

func (*Statements) Enum added in v0.0.65

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

func (*Statements) Raw added in v0.0.65

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

func (*Statements) Serialize added in v0.0.65

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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