config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: CC0-1.0 Imports: 8 Imported by: 1

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 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

func ExportTypes

func ExportTypes(ts *guts.Typescript)

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

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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