Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (g *Goty) parseSlice(parent *DataStruct, field reflect.Type, member *Struct
}

name, optional := g.parseMember(parent, field.Elem(), member)
if optional {
if optional && g.config.override(field).NullSlicePointers {
name = "(null | " + name + ")"
}

Expand Down
5 changes: 5 additions & 0 deletions entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type Config struct {
type Overrides map[any]Override

// Override is a struct that contains overrides for either a specific type or for all types (when global).
//
//nolint:lll // Can't break this up I don't think.
type Override struct {
// Namer is a function that can be used to customize the typescript interface name.
// Use this to add a prefix, suffix or any custom name changes you wish.
Expand Down Expand Up @@ -73,6 +75,9 @@ type Override struct {
UsePkgName UsePkgName `json:"usePkgName" toml:"use_pkg_name" xml:"use-pkg-name" yaml:"usePkgName"`
// By default all typescript interfaces are exported. Set NoExport to true to prevent that.
NoExport bool `json:"noExport" toml:"no_export" xml:"no-export" yaml:"noExport"`
// Setting NullSlicePointers to true causes the builder to add | null to slices of pointers.
// If your pointer slices are nullable, set this to true.
NullSlicePointers bool `json:"nullSlicePointers" toml:"null_slice_pointers" xml:"null-slice-pointers" yaml:"nullSlicePointers"`
}

// Namer is an interface that allows external interface naming.
Expand Down
1 change: 1 addition & 0 deletions printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func ExampleGoty_Print() {
// keepUnderscores: boolean;
// usePkgName: number;
// noExport: boolean;
// nullSlicePointers: boolean;
// };
//
// // Packages parsed:
Expand Down
Loading