Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Root directory to scan for go source files RootDir string `json:"rootDir"` Types TypesConfig `json:"types,omitempty"` // Output options Output Output `json:"output,omitempty"` // Whether to scan directories recursively Recursive bool `json:"recursive,omitempty"` // Custom global transformation // Allows applying gots options globally to specific types instead of using gots tags in code Transforms []*Transform `json:"transforms"` // Paths/globs to include // If unset, all files found in root directory will be parsed (and subdirectories if recursive is set) Include []string `json:"include,omitempty"` // Paths/globs to exclude Exclude []string `json:"exclude,omitempty"` }
Parser options
type Constant ¶
type Constant struct { Name string `json:"name"` // Constant name Type *Type `json:"type"` // Constant type Value string `json:"value"` // Constant value EnumValue bool `json:"enumValue"` // This const defines an enum value EnumName string `json:"enumName"` // Enum name that this const defines a value for }
type ExtendsInterface ¶
type ExtendsInterface struct { Name string `json:"name"` // Interface name From string `json:"from"` // Name of package containing this interface }
interface extension opts
type File ¶
type File struct { Constants []*Constant `json:"constants"` // constants Interfaces []*Interface `json:"interfaces"` // interfaces Types []*TypeAlias `json:"types"` // types Enums []*Enum `json:"enums"` // enums EnumValues []*Constant `json:"enumValues"` SourcePath string `json:"sourcePath"` // original source path }
contains interfaces, types, and constants that were found in the same file
func (*File) EachInterface ¶
type Interface ¶
type Interface struct { Name string `json:"name"` // Interface name Properties []*Property `json:"properties,omitempty"` // Interface properties Extends *ExtendsInterface `json:"extends,omitempty"` // Extends another interface }
interface options
type Output ¶
type Output struct { // Output mode // Defaults to packages Mode OutputMode `json:"mode,omitempty"` // Root directory to output file(s) to // Default to current directory Path string `json:"path,omitempty"` // Filename to use when using AIO mode // Defaults to `types.ts` AIOFileName string `json:"aioFileName,omitempty"` }
Output config
type OutputMode ¶
type OutputMode string
Enum for output modes
const ( // output all parsed types in a single file AIO OutputMode = "aio" // output each package into a separate file Packages OutputMode = "packages" // output directories and files that match the go source code Mirror OutputMode = "mirror" )
type Package ¶
type Package struct { Name string `json:"name"` Files []string `json:"files"` PkgAst *ast.Package `json:"-"` FilesAst []*ast.File `json:"-"` Consts map[string]*Constant `json:"constants"` // constants Structs map[string]*Interface `json:"structs"` Interfaces map[string]*Interface `json:"interfaces"` // interfaces Types map[string]*TypeAlias `json:"types"` // types Enums map[string]*Enum `json:"enums"` // enums EnumValues map[string]*Constant `json:"enumValues"` Decls []ast.Decl ConstDecls []*ast.GenDecl StructDecls []*ast.TypeSpec InterfaceDecls []*ast.TypeSpec TypeDecls []*ast.TypeSpec Path string `json:"path"` // original source path }
Package represents a group of files that exist in the same file/module
type Property ¶
type Property struct { Name string `json:"name"` // Property name Type *Type `json:"type"` // Property type Optional bool `json:"optional"` // Property is optional Inline bool `json:"inline"` }
property options
type ReadConfig ¶
func (*ReadConfig) Directories ¶
func (rc *ReadConfig) Directories() ([]string, error)
func (*ReadConfig) Files ¶
func (rc *ReadConfig) Files() ([]string, error)
Returns a list of files matching the provided config
type ReadFn ¶
type ReadFn func(config *ReadConfig) (Spec, error)
type Spec ¶
type Spec interface {
Packages() []*Package // Returns the packages that were parsed
}
Root scope that contains uniform description of interfaces, types, constants, enums... etc
type Transform ¶
type Transform struct { // Regex pattern to replace Pattern string `json:"pattern,omitempty"` // Exact type to replace // Ignored if pattern is set Type string `json:"type,omitempty"` // Type to use instead of pattern/from Target string `json:"target,omitempty"` // Force matches to be optional // If not set, it will fall back to default behaviour (parse tags) Optional bool `json:"optional,omitempty"` }
Transform config
type Type ¶
type Type struct { Name string `json:"name"` // Type name From string `json:"from"` // Package name that contains this type EnumValue bool `json:"enumValue"` Generic bool `json:"generic"` // Type is generic Array bool `json:"array"` // Type is an array Map bool `json:"bool"` // Type is a map MapKey *Type `json:"mapKey"` // Map key type MapValue *Type `json:"mapValue"` // Map value type // Whether this type is a pointer Pointer bool `json:"pointer"` }
Typescript type options
type TypeAlias ¶
type TypeAlias struct { Name string `json:"name"` // Alias name AliasedType *Type `json:"aliasedType"` // Aliased type }
Opts for TypeScript type alias
type TypesConfig ¶
type TypesConfig struct { // Go interfaces Interfaces bool `json:"interfaces"` // Variable declarations that have default values Variables bool `json:"variables"` // Const declarations Constants bool `json:"constants"` // Type aliases Aliases bool `json:"aliases"` // Go structs Structs bool `json:"structs"` // Generate enum from type alias and constant combinations Enums bool `json:"enums"` }
Configures what types to export
type WriteConfig ¶
Click to show internal directories.
Click to hide internal directories.