typeinfo

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package typeinfo provides shared type inference from a Node tree. It is used by the typegen lens to generate Go structs, TypeScript interfaces, and JSON Schema. The inference handles nullable fields and merges shapes across array elements.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldInfo

type FieldInfo struct {
	Name     string
	GoName   string // PascalCase
	Type     *TypeInfo
	Nullable bool // true if the field was null in any observed sample
}

FieldInfo describes a single field in an inferred object type.

type TypeInfo

type TypeInfo struct {
	Kind     TypeKind
	Nullable bool

	// For TypeObject
	Fields []*FieldInfo // ordered by first observed key

	// For TypeArray
	Elem *TypeInfo // unified element type
}

TypeInfo is the inferred type for a node or set of nodes.

func Infer

func Infer(n *node.Node) *TypeInfo

Infer derives a TypeInfo from a node, merging across all array elements.

type TypeKind

type TypeKind uint8

TypeKind classifies inferred types.

const (
	TypeNull TypeKind = iota
	TypeBool
	TypeNumber
	TypeString
	TypeArray
	TypeObject
	TypeMixed // multiple incompatible types observed
)

Jump to

Keyboard shortcuts

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