config

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 License: CC0-1.0 Imports: 8 Imported by: 2

Documentation

Overview

Package config provides standard configurations for the guts package. These configurations are useful for common use cases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BiomeLintIgnoreAnyTypeParameters

func BiomeLintIgnoreAnyTypeParameters(ts *guts.Typescript)

BiomeLintIgnoreAnyTypeParameters adds a biome-ignore comment to any type parameters that are of type "any". It is questionable if we should even add 'extends any' at all to the typescript.

func EnumAsTypes added in v1.3.0

func EnumAsTypes(ts *guts.Typescript)

EnumAsTypes uses types to handle enums rather than using 'enum'. An enum will look like:

type EnumString = "bar" | "baz" | "foo" | "qux";

func EnumLists

func EnumLists(ts *guts.Typescript)

EnumLists adds a constant that lists all the values in a given enum. Example: type MyEnum = string const ( EnumFoo = "foo" EnumBar = "bar" ) const MyEnums: string = ["foo", "bar"] <-- this is added TODO: Enums were changed to use proper enum types. This should be

updated to support that. EnumLists only works with EnumAsTypes used first.

func ExportTypes

func ExportTypes(ts *guts.Typescript)

ExportTypes adds 'export' to all top level types. interface Foo {} --> export interface Foo{}

func NotNullMaps added in v1.2.0

func NotNullMaps(ts *guts.Typescript)

NotNullMaps assumes all maps will not be null. Example: GolangType: map[string]string TsType: Record<string,string> | null --> Record<string,string>

func NullUnionSlices added in v1.1.0

func NullUnionSlices(ts *guts.Typescript)

NullUnionSlices converts slices with nullable elements to remove the 'null' type from the union. This happens when a golang pointer is the element type of a slice. Example: GolangType: []*string TsType: (string | null)[] --> (string)[] TODO: Somehow remove the parenthesis from the output type. Might have to change the node from a union type to it's first element.

func OverrideLiteral

func OverrideLiteral(keyword bindings.LiteralKeyword) guts.TypeOverride

func OverrideNullable

func OverrideNullable(t guts.TypeOverride) guts.TypeOverride

func ReadOnly

func ReadOnly(ts *guts.Typescript)

ReadOnly sets all interface fields to 'readonly', resulting in all types being immutable. TODO: follow the AST all the way and find nested arrays

func SimplifyOmitEmpty

func SimplifyOmitEmpty(ts *guts.Typescript)

SimplifyOmitEmpty removes the null type from union types that have a question token. This is because if 'omitempty' is set, then golang will omit the object key, rather than sending a null value to the client. Example: number?: number | null --> number?: number

func StandardMappings

func StandardMappings() map[string]guts.TypeOverride

StandardMappings is a list of standard mappings for Go types to Typescript types.

func TrimEnumPrefix added in v1.3.0

func TrimEnumPrefix(ts *guts.Typescript)

TrimEnumPrefix removes the enum name from the member names.

Types

This section is empty.

Jump to

Keyboard shortcuts

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