Documentation
¶
Index ¶
- func StringLiteralUnion(values ...string) string
- func Union(types ...string) string
- type GoTypeRegistry
- type GoTypeSrc
- type ID
- type ResolvedTSType
- type ResolvedTSTypes
- type TSDrafter
- func (d *TSDrafter) Const(name string, val any) *TSDrafter
- func (d *TSDrafter) Enum(const_name, type_name string, val any) *TSDrafter
- func (d *TSDrafter) ExportConst(name string, val any) *TSDrafter
- func (d *TSDrafter) ExportEnum(const_name, type_name string, val any) *TSDrafter
- func (d *TSDrafter) ExportType(name string, val string) *TSDrafter
- func (d *TSDrafter) Raw(content string) *TSDrafter
- func (d *TSDrafter) String() string
- func (d *TSDrafter) Type(name string, val string) *TSDrafter
- type TSTyper
- type TSTyperRaw
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StringLiteralUnion ¶
StringLiteralUnion produces a TypeScript string literal union type, e.g. "active" | "inactive" | "pending".
Types ¶
type GoTypeRegistry ¶
type GoTypeRegistry struct {
// contains filtered or unexported fields
}
GoTypeRegistry collects Go types and resolves them into TypeScript definitions.
func (*GoTypeRegistry) Add ¶
func (r *GoTypeRegistry) Add(input_types ...*GoTypeSrc)
Add registers one or more Go types for TypeScript generation.
func (*GoTypeRegistry) ResolveTypes ¶
func (r *GoTypeRegistry) ResolveTypes() (ResolvedTSTypes, error)
ResolveTypes walks all registered types, deduplicates, resolves name collisions, and returns the final map of type definitions keyed by ID.
type ResolvedTSType ¶
type ResolvedTSType struct {
ID ID
Name string // Resolved, unique TS name (e.g. "UserResponse")
Body string // The TS type body (e.g. "{ id: string; name: string }")
}
ResolvedTSType is a single resolved type definition.
type ResolvedTSTypes ¶
type ResolvedTSTypes map[ID]ResolvedTSType
type TSDrafter ¶
type TSDrafter struct {
// contains filtered or unexported fields
}
TSDrafter is a builder for producing TypeScript const, type, and enum declarations. It implements fmt.Stringer.
func (*TSDrafter) ExportEnum ¶
type TSTyper ¶
TSTyper lets a struct override specific field types or add extra fields. Keys are Go field names. Values are literal TS type strings, or sentinel IDs obtained from Type.ID() for referencing system-managed types.
type TSTyperRaw ¶
type TSTyperRaw interface {
TSType() string
}
TSTyperRaw lets a struct bypass reflection entirely. The returned string becomes the whole TS type body verbatim.